MediaCostController.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. ['advertiser_id', ''],
  46. ['agent_id', ''],
  47. ['site_id', ''],
  48. ['auth_id', ''],
  49. ['add_type', ''],
  50. ['remark', ''],
  51. ['create_time', ''],
  52. ]);
  53. $query = $this->logic->search($where);
  54. // 游戏权限过滤
  55. if($request->get('auth_game_list')){
  56. $gameIds = explode(',', $request->get('auth_game_list'));
  57. $query->whereIn('game_id', $gameIds);
  58. }
  59. $data = $this->logic->getList($query)['data'];
  60. $data = $this->logic->trandformListColumn($data, ['site', 'agent', 'game', 'auth','media']);
  61. return $this->success($data);
  62. }
  63. /**
  64. * 保存媒体消耗
  65. */
  66. public function save(Request $request): Response
  67. {
  68. $data = $request->post();
  69. $this->logic->save($data);
  70. return $this->success();
  71. }
  72. }