Jelajahi Sumber

修改静态调用

Anyon 2 tahun lalu
induk
melakukan
2fd2d3938e

+ 1 - 1
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']}]代理绑定成功!");
 
         // 更新下级的代理关系

+ 1 - 1
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} 个用户等级。");

+ 2 - 2
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);
     }
 }

+ 1 - 1
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 {

+ 1 - 1
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'],

+ 2 - 2
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);
         }
     }
 

+ 1 - 1
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] = [[], []];

+ 7 - 6
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);
     }
 }