MediaCostController.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | saiadmin [ saiadmin快速开发框架 ]
  4. // +----------------------------------------------------------------------
  5. // | Author: your name
  6. // +----------------------------------------------------------------------
  7. namespace app\v1\controller\advert;
  8. use app\v1\logic\advert\AgentListLogic;
  9. use app\v1\logic\advert\AgentSiteLogic;
  10. use plugin\saiadmin\basic\BaseController;
  11. use app\v1\logic\advert\MediaCostLogic;
  12. use app\v1\logic\center\GameLogic;
  13. use app\v1\validate\advert\MediaCostValidate;
  14. use plugin\saiadmin\app\logic\system\SystemUserLogic;
  15. use support\Request;
  16. use support\Response;
  17. /**
  18. * 媒体消耗控制器
  19. */
  20. class MediaCostController extends BaseController
  21. {
  22. protected $agentSiteLogic;
  23. protected $agentListLogic;
  24. protected $gameLogic;
  25. protected $systemUserLogic;
  26. /**
  27. * 构造函数
  28. */
  29. public function __construct()
  30. {
  31. $this->logic = new MediaCostLogic();
  32. $this->validate = new MediaCostValidate;
  33. parent::__construct();
  34. $this->agentSiteLogic = new AgentSiteLogic();
  35. $this->agentListLogic = new AgentListLogic();
  36. $this->gameLogic = new GameLogic();
  37. $this->systemUserLogic = new SystemUserLogic();
  38. }
  39. /**
  40. * 数据列表
  41. * @param Request $request
  42. * @return Response
  43. */
  44. public function index(Request $request): Response
  45. {
  46. $where = $request->more([
  47. ['tdate', ''],
  48. ['game_id', ''],
  49. ['media_id', ''],
  50. ['agent_id', ''],
  51. ['site_id', ''],
  52. ['auth_id', ''],
  53. ['add_type', ''],
  54. ['remark', ''],
  55. ['create_time', ''],
  56. ]);
  57. $query = $this->logic->search($where);
  58. // 游戏权限过滤
  59. if($request->get('auth_game_list')){
  60. $gameIds = explode(',', $request->get('auth_game_list'));
  61. $query->whereIn('game_id', $gameIds);
  62. }
  63. $data = $this->logic->getList($query)['data'];
  64. $data = $this->logic->trandformListColumn($data, ['site', 'agent', 'game', 'auth']);
  65. return $this->success($data);
  66. }
  67. /**
  68. * 保存媒体消耗
  69. */
  70. public function save(Request $request): Response
  71. {
  72. $data = $request->post();
  73. $this->logic->save($data);
  74. return $this->success();
  75. }
  76. }