Kaynağa Gözat

打包管理

ith5 6 ay önce
ebeveyn
işleme
6dc10dc8de

+ 13 - 6
app/v1/controller/CommonController.php

@@ -6,6 +6,7 @@ use app\v1\logic\advert\MediaListLogic;
 use app\v1\logic\center\GameLogic;
 use plugin\saiadmin\basic\BaseController;
 use app\v1\logic\center\GameMainLogic;
+use app\v1\logic\gameLog\GamePackageLogic;
 use plugin\saiadmin\app\logic\system\SystemUserLogic;
 use support\Request;
 use support\Response;
@@ -20,6 +21,7 @@ class CommonController extends BaseController
     protected $mediaListLogic;
     protected $agentListLogic;
     protected $systemUserLogic;
+    protected $gamePackageLogic;
 
     /**
      * 构造函数
@@ -32,6 +34,7 @@ class CommonController extends BaseController
         $this->mediaListLogic = new MediaListLogic();
         $this->agentListLogic = new AgentListLogic();
         $this->systemUserLogic = new SystemUserLogic();
+        $this->gamePackageLogic = new GamePackageLogic();
     }
     
     /**
@@ -75,12 +78,7 @@ class CommonController extends BaseController
     {
         $data = $this->mediaListLogic->getMediaOptions();
         $data = $data->toArray();
-        $data = array_map(function ($item) {
-            return [
-                'label' => $item['name'].'【' . $item['id'] . '】',
-                'value' => $item['id'],
-            ];
-        }, $data);
+        
 
         return $this->success($data);
     }
@@ -102,4 +100,13 @@ class CommonController extends BaseController
         $data = $this->systemUserLogic->field('id as value, username as label')->select()->toArray();
         return $this->success($data);
     }
+
+    /**
+     * 获取母包列表Options
+     */
+    public function getPackageOptions(Request $request): Response
+    {
+        $data = $this->gamePackageLogic->getPackageOptions();
+        return $this->success($data);
+    }
 }

+ 6 - 6
app/v1/controller/advert/AgentListController.php

@@ -43,13 +43,13 @@ class AgentListController extends BaseController
         ]);
         $query = $this->logic->search($where);
         $data = $this->logic->getList($query);
-        $userListData = array_column($this->systemUserLogic->field('id,username')->select()->toArray(),'username','id');
+        // $userListData = array_column($this->systemUserLogic->field('id,username')->select()->toArray(),'username','id');
+        $data=$this->logic->trandformListColumn($data['data'],['auth','media']);
 
-
-        $data['data'] = array_map(function ($item) use ($userListData) {
-            $item['auth_name'] = $userListData[$item['auth_id']] ?? '';
-            return $item;
-        }, $data['data']);
+        // $data['data'] = array_map(function ($item) use ($userListData) {
+        //     $item['auth_name'] = $userListData[$item['auth_id']] ?? '';
+        //     return $item;
+        // }, $data['data']);
 
         return $this->success($data);
     }

+ 46 - 0
app/v1/controller/gameLog/GamePackLogController.php

@@ -0,0 +1,46 @@
+<?php
+// +----------------------------------------------------------------------
+// | saiadmin [ saiadmin快速开发框架 ]
+// +----------------------------------------------------------------------
+// | Author: your name
+// +----------------------------------------------------------------------
+namespace app\v1\controller\gameLog;
+
+use plugin\saiadmin\basic\BaseController;
+use app\v1\logic\gameLog\GamePackLogLogic;
+use app\v1\validate\gameLog\GamePackLogValidate;
+use support\Request;
+use support\Response;
+
+/**
+ * 打包记录控制器
+ */
+class GamePackLogController extends BaseController
+{
+    /**
+     * 构造函数
+     */
+    public function __construct()
+    {
+        $this->logic = new GamePackLogLogic();
+        $this->validate = new GamePackLogValidate;
+        parent::__construct();
+    }
+
+    /**
+     * 数据列表
+     * @param Request $request
+     * @return Response
+     */
+    public function index(Request $request): Response
+    {
+        $where = $request->more([
+            ['game_name', ''],
+        ]);
+        $query = $this->logic->search($where);
+        $data = $this->logic->getList($query);
+        $data['data'] = $this->logic->trandformListColumn($data['data'],['agent','site','package']);
+        return $this->success($data);
+    }
+
+}

+ 48 - 0
app/v1/controller/gameLog/GamePackageController.php

@@ -0,0 +1,48 @@
+<?php
+// +----------------------------------------------------------------------
+// | saiadmin [ saiadmin快速开发框架 ]
+// +----------------------------------------------------------------------
+// | Author: your name
+// +----------------------------------------------------------------------
+namespace app\v1\controller\gameLog;
+
+use plugin\saiadmin\basic\BaseController;
+use app\v1\logic\gameLog\GamePackageLogic;
+use app\v1\validate\gameLog\GamePackageValidate;
+use support\Request;
+use support\Response;
+
+/**
+ * 母包管理控制器
+ */
+class GamePackageController extends BaseController
+{
+    /**
+     * 构造函数
+     */
+    public function __construct()
+    {
+        $this->logic = new GamePackageLogic();
+        $this->validate = new GamePackageValidate;
+        parent::__construct();
+    }
+
+    /**
+     * 数据列表
+     * @param Request $request
+     * @return Response
+     */
+    public function index(Request $request): Response
+    {
+        $where = $request->more([
+            ['media_id', ''],
+            ['game_id', ''],
+        ]);
+
+        $query = $this->logic->search($where);
+        $data = $this->logic->getList($query);
+        $data = $this->logic->trandformListColumn($data['data'], ['media', 'game']);
+        return $this->success($data);
+    }
+
+}

+ 2 - 7
app/v1/logic/advert/AgentListLogic.php

@@ -29,13 +29,8 @@ class AgentListLogic extends BaseLogic
      */
     public function getAgentOptions()
     {
-        $data = $this->model->field('id as value,name as label')->select()->toArray();
-        $data = array_map(function ($item) {
-            return [
-                'label' => $item['label'].'【' . $item['value'] . '】' ,
-                'value' => $item['value'],
-            ];
-        }, $data);
+        $data = $this->model->select()->toArray();
+
         return $data;
     }
 }

+ 0 - 23
app/v1/logic/advert/MediaCostLogic.php

@@ -48,27 +48,4 @@ class MediaCostLogic extends BaseLogic
         $this->model->save($data);
     }
 
-    public function trandformListColumn($data, $fields=['site', 'agent', 'game', 'auth']){
-
-        if(in_array('site', $fields)){
-            $agentSiteList = $this->agentSiteLogic->field('id,name')->column('name', 'id');
-        }
-        if(in_array('agent', $fields)){
-            $agentList = $this->agentListLogic->field('id,name')->column('name', 'id');
-        }
-        if(in_array('game', $fields)){
-            $gameList = $this->gameLogic->field('id,name')->select()->column('name', 'id');
-        }
-        if(in_array('auth', $fields)){
-            $authList = $this->systemUserLogic->field('id,username')->column('username', 'id');
-        }
-
-        foreach ($data as $key => $value) {
-            $data[$key]['site_name'] = $agentSiteList ? $agentSiteList[$value['site_id']] ?? '':'';
-            $data[$key]['agent_name'] = $agentList ? $agentList[$value['agent_id']] ?? '':'';
-            $data[$key]['game_name'] = $gameList ? $gameList[$value['game_id']] ?? '':'';
-            $data[$key]['auth_name'] = $authList ? $authList[$value['auth_id']] ?? '':'';
-        }
-        return $data;
-    }
 }

+ 1 - 1
app/v1/logic/center/GameLogic.php

@@ -60,7 +60,7 @@ class GameLogic extends BaseLogic
     public function getGameOptions($where)
     {
         $auth_game_list = request()->header('auth_game_list');
-        $query = $this->field('id as value,name as label');
+        $query = $this->search($where);
         if(!empty($auth_game_list)) {
             $authGameList = explode(',', $auth_game_list);
             $query->where('id', 'in', $authGameList);

+ 28 - 0
app/v1/logic/gameLog/GamePackLogLogic.php

@@ -0,0 +1,28 @@
+<?php
+// +----------------------------------------------------------------------
+// | saiadmin [ saiadmin快速开发框架 ]
+// +----------------------------------------------------------------------
+// | Author: your name
+// +----------------------------------------------------------------------
+namespace app\v1\logic\gameLog;
+
+use plugin\saiadmin\basic\BaseLogic;
+use plugin\saiadmin\exception\ApiException;
+use plugin\saiadmin\utils\Helper;
+use app\v1\model\gameLog\GamePackLog;
+
+/**
+ * 打包记录逻辑层
+ */
+class GamePackLogLogic extends BaseLogic
+{
+    /**
+     * 构造函数
+     */
+    public function __construct()
+    {
+        $this->model = new GamePackLog();
+    }
+    
+
+}

+ 35 - 0
app/v1/logic/gameLog/GamePackageLogic.php

@@ -0,0 +1,35 @@
+<?php
+// +----------------------------------------------------------------------
+// | saiadmin [ saiadmin快速开发框架 ]
+// +----------------------------------------------------------------------
+// | Author: your name
+// +----------------------------------------------------------------------
+namespace app\v1\logic\gameLog;
+
+use plugin\saiadmin\basic\BaseLogic;
+use plugin\saiadmin\exception\ApiException;
+use plugin\saiadmin\utils\Helper;
+use app\v1\model\gameLog\GamePackage;
+
+/**
+ * 母包管理逻辑层
+ */
+class GamePackageLogic extends BaseLogic
+{
+    /**
+     * 构造函数
+     */
+    public function __construct()
+    {
+        $this->model = new GamePackage();
+    }
+
+    /**
+     * 获取母包Options
+     */
+    public function getPackageOptions()
+    {
+        $data = $this->model->select()->toArray();
+        return $data;
+    }
+}

+ 42 - 0
app/v1/model/gameLog/GamePackLog.php

@@ -0,0 +1,42 @@
+<?php
+// +----------------------------------------------------------------------
+// | saiadmin [ saiadmin快速开发框架 ]
+// +----------------------------------------------------------------------
+// | Author: your name
+// +----------------------------------------------------------------------
+namespace app\v1\model\gameLog;
+
+use plugin\saiadmin\basic\BaseNormalModel;
+
+/**
+ * 打包记录模型
+ */
+class GamePackLog extends BaseNormalModel
+{
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 数据库表名称
+     * @var string
+     */
+    protected $table = 'game_pack_log';
+
+    /**
+     * 数据库连接
+     * @var string
+     */
+    protected $connection = 'db_game_log';
+
+    /**
+     * 游戏名 搜索
+     */
+    public function searchGameNameAttr($query, $value)
+    {
+        $query->where('game_name', 'like', '%'.$value.'%');
+    }
+
+}

+ 34 - 0
app/v1/model/gameLog/GamePackage.php

@@ -0,0 +1,34 @@
+<?php
+// +----------------------------------------------------------------------
+// | saiadmin [ saiadmin快速开发框架 ]
+// +----------------------------------------------------------------------
+// | Author: your name
+// +----------------------------------------------------------------------
+namespace app\v1\model\gameLog;
+
+use plugin\saiadmin\basic\BaseNormalModel;
+
+/**
+ * 母包管理模型
+ */
+class GamePackage extends BaseNormalModel
+{
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 数据库表名称
+     * @var string
+     */
+    protected $table = 'game_package';
+
+    /**
+     * 数据库连接
+     * @var string
+     */
+    protected $connection = 'db_game_log';
+
+}

+ 53 - 0
app/v1/validate/gameLog/GamePackLogValidate.php

@@ -0,0 +1,53 @@
+<?php
+// +----------------------------------------------------------------------
+// | saiadmin [ saiadmin快速开发框架 ]
+// +----------------------------------------------------------------------
+// | Author: your name
+// +----------------------------------------------------------------------
+namespace app\v1\validate\gameLog;
+
+use think\Validate;
+
+/**
+ * 打包记录验证器
+ */
+class GamePackLogValidate extends Validate
+{
+    /**
+     * 定义验证规则
+     */
+    protected $rule =   [
+        'package_id' => 'require',
+    ];
+
+    /**
+     * 定义错误信息
+     */
+    protected $message  =   [
+        'package_id' => '母包ID必须填写',
+       
+    ];
+
+    /**
+     * 定义场景
+     */
+    protected $scene = [
+        'save' => [
+            'package_id',
+            'letter',
+            'game_id',
+            'agent_id',
+            'site_id',
+            'icon',
+        ],
+        'update' => [
+            'package_id',
+            'letter',
+            'game_id',
+            'agent_id',
+            'site_id',
+            'icon',
+        ],
+    ];
+
+}

+ 58 - 0
app/v1/validate/gameLog/GamePackageValidate.php

@@ -0,0 +1,58 @@
+<?php
+// +----------------------------------------------------------------------
+// | saiadmin [ saiadmin快速开发框架 ]
+// +----------------------------------------------------------------------
+// | Author: your name
+// +----------------------------------------------------------------------
+namespace app\v1\validate\gameLog;
+
+use think\Validate;
+
+/**
+ * 母包管理验证器
+ */
+class GamePackageValidate extends Validate
+{
+    /**
+     * 定义验证规则
+     */
+    protected $rule =   [
+        'media_id' => 'require',
+        'game_id' => 'require',
+        'name' => 'require',
+        'package_name' => 'require',
+        'appid' => 'require',
+    ];
+
+    /**
+     * 定义错误信息
+     */
+    protected $message  =   [
+        'media_id' => '媒体ID必须填写',
+        'game_id' => '游戏ID必须填写',
+        'name' => '母包名称必须填写',
+        'package_name' => '母包包名com.xxx必须填写',
+        'appid' => '媒体APPID必须填写',
+    ];
+
+    /**
+     * 定义场景
+     */
+    protected $scene = [
+        'save' => [
+            'media_id',
+            'game_id',
+            'name',
+            'package_name',
+            'appid',
+        ],
+        'update' => [
+            'media_id',
+            'game_id',
+            'name',
+            'package_name',
+            'appid',
+        ],
+    ];
+
+}

+ 51 - 0
plugin/saiadmin/basic/BaseLogic.php

@@ -263,6 +263,57 @@ class BaseLogic
         return $query->select()->toArray();
     }
 
+
+    /**
+     * 转换列表列
+     * @param $data
+     * @param $fields
+     * @return mixed
+     */
+    public function trandformListColumn($data, $fields=['site', 'agent', 'game', 'auth', 'media', 'package']){
+
+        if(in_array('site', $fields)){
+            $agentSiteList = Db::connect('db_advert')->table('agent_site')->field('id,name')->select()->toArray();
+            $agentSiteList = array_column($agentSiteList, 'name', 'id');
+          
+        }
+        if(in_array('agent', $fields)){
+            $agentList = Db::connect('db_advert')->table('agent_list')->field('id,name')->select()->toArray();
+            $agentList = array_column($agentList, 'name', 'id');
+           
+        }
+        if(in_array('game', $fields)){
+            $gameList = Db::connect('db_center')->table('pf_game')->field('id,name')->select()->toArray();
+            $gameList = array_column($gameList, 'name', 'id');
+           
+        }
+        if(in_array('auth', $fields)){
+            $authList = Db::connect('db_system')->table('sa_system_user')->field('id,username')->select()->toArray();
+            $authList = array_column($authList, 'username', 'id');
+          
+        }
+        if(in_array('media', $fields)){
+            $mediaList = Db::connect('db_advert')->table('media_list')->field('id,name')->select()->toArray();
+            $mediaList = array_column($mediaList, 'name', 'id');
+        }
+        if(in_array('package', $fields)){
+            $packageList = Db::connect('db_game_log')->table('game_package')->field('id,name')->select()->toArray();
+            $packageList = array_column($packageList, 'name', 'id');
+        }
+
+
+        foreach ($data as $key => $value) {
+    
+            $data[$key]['site_name'] = !empty($agentSiteList) ? $agentSiteList[$value['site_id']] ?? '':'';
+            $data[$key]['agent_name'] = !empty($agentList) ? $agentList[$value['agent_id']] ?? '':'';
+            $data[$key]['game_name'] = !empty($gameList) ? $gameList[$value['game_id']] ?? '':'';
+            $data[$key]['auth_name'] = !empty($authList) ? $authList[$value['auth_id']] ?? '':'';
+            $data[$key]['media_name'] = !empty($mediaList) ? $mediaList[$value['media_id']] ?? '':'';
+            $data[$key]['package_name'] = !empty($packageList) ? $packageList[$value['package_id']] ?? '':'';
+        }
+        return $data;
+    }
+
     /**
      * 获取上传的导入文件
      * @param $file