diff --git a/app/data/command/UserAgent.php b/app/data/command/UserAgent.php index a2aaca7bf..fd18ac27d 100644 --- a/app/data/command/UserAgent.php +++ b/app/data/command/UserAgent.php @@ -58,7 +58,7 @@ class UserAgent extends Command 'path' => $path1, 'layer' => substr_count($path1, '-'), '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']}]代理绑定成功!"); // 更新下级的代理关系 diff --git a/app/data/command/UserUpgrade.php b/app/data/command/UserUpgrade.php index 613e0e598..c2ceac0c6 100644 --- a/app/data/command/UserUpgrade.php +++ b/app/data/command/UserUpgrade.php @@ -34,7 +34,7 @@ class UserUpgrade extends Command [$total, $count] = [DataUser::mk()->count(), 0]; foreach (DataUser::mk()->field('id')->cursor() as $user) { $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->setQueueSuccess("此次共重新计算 {$total} 个用户等级。"); diff --git a/app/data/controller/api/News.php b/app/data/controller/api/News.php index 28b7923d9..e6879bdba 100644 --- a/app/data/controller/api/News.php +++ b/app/data/controller/api/News.php @@ -47,7 +47,7 @@ class News extends Controller $query = DataNewsItem::mQuery()->like('name,mark')->equal('id,code'); $query->where(['deleted' => 0, 'status' => 1])->withoutField('sort,status,deleted'); $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); } @@ -62,7 +62,7 @@ class News extends Controller $map = $this->_vali(['code.require' => '文章不能为空!']); $query = DataNewsXCollect::mQuery()->where(['type' => 4, 'status' => 2]); $result = $query->where($map)->order('id desc')->page(true, false, false, 15); - NewsService::instance()->buildListByUidAndCode($result['list']); + NewsService::buildListByUidAndCode($result['list']); $this->success('获取评论成功', $result); } } \ No newline at end of file diff --git a/app/data/controller/api/auth/Center.php b/app/data/controller/api/auth/Center.php index 7327d932e..b0a038cb8 100644 --- a/app/data/controller/api/auth/Center.php +++ b/app/data/controller/api/auth/Center.php @@ -140,7 +140,7 @@ class Center extends Auth public function bindFrom() { $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) { $this->success($message, UserAdminService::total($this->uuid)); } else { diff --git a/app/data/controller/base/postage/Company.php b/app/data/controller/base/postage/Company.php index 4f5431075..8ff38586a 100644 --- a/app/data/controller/base/postage/Company.php +++ b/app/data/controller/base/postage/Company.php @@ -96,7 +96,7 @@ class Company extends Controller public function sync() { try { - $result = ExpressService::instance()->company(); + $result = ExpressService::company(); if (empty($result['code'])) $this->error($result['info']); foreach ($result['data'] as $vo) BasePostageCompany::mUpdate([ 'name' => $vo['title'], diff --git a/app/data/controller/base/postage/Template.php b/app/data/controller/base/postage/Template.php index 36684cf61..ef7a327fb 100644 --- a/app/data/controller/base/postage/Template.php +++ b/app/data/controller/base/postage/Template.php @@ -43,7 +43,7 @@ class Template extends Controller { if ($this->request->isGet()) { $this->title = '配送区域管理'; - $this->citys = ExpressService::instance()->region(3, null); + $this->citys = ExpressService::region(3, null); $this->fetch('form_region'); } else { $data = $this->_vali(['nos.default' => '', 'oks.default' => '']); @@ -83,7 +83,7 @@ class Template extends Controller $data['code'] = CodeExtend::uniqidDate(12, 'T'); } if ($this->request->isGet()) { - $this->citys = ExpressService::instance()->region(2, 1); + $this->citys = ExpressService::region(2, 1); } } diff --git a/app/data/service/NewsService.php b/app/data/service/NewsService.php index 94bf4cd31..83da1564b 100644 --- a/app/data/service/NewsService.php +++ b/app/data/service/NewsService.php @@ -57,7 +57,7 @@ class NewsService extends Service * @param integer $uuid 用户UID * @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) { [$code2, $code1] = [[], []]; diff --git a/app/data/service/UserUpgradeService.php b/app/data/service/UserUpgradeService.php index 3a6aadbe0..bcec00b3e 100644 --- a/app/data/service/UserUpgradeService.php +++ b/app/data/service/UserUpgradeService.php @@ -7,6 +7,7 @@ use app\data\model\DataUser; use app\data\model\DataUserBalance; use app\data\model\ShopOrder; use app\data\model\ShopOrderItem; +use think\admin\Library; use think\admin\Service; /** @@ -27,7 +28,7 @@ class UserUpgradeService extends Service * @throws \think\db\exception\DbException * @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(); if (empty($user)) return [0, '查询用户资料失败']; @@ -41,7 +42,7 @@ class UserUpgradeService extends Service if (empty($agent['vip_code'])) return [0, '代理无推荐资格']; if (strpos($agent['path'], "-{$uuid}-") !== false) return [0, '不能绑定下属']; 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']}-"; $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, '绑定代理成功']; } catch (\Exception $exception) { return [0, "绑定代理失败, {$exception->getMessage()}"]; @@ -71,7 +72,7 @@ class UserUpgradeService extends Service * @throws \think\db\exception\DbException * @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(); 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'); 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, ]); - return !($parent && $user['pid1'] > 0) || $this->upgrade($user['pid1'], false); + return !($parent && $user['pid1'] > 0) || static::upgrade($user['pid1'], false); } } \ No newline at end of file