MediaCostController.php 2.1 KB

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