logic = new GameLogic(); $this->validate = new GameValidate; $this->systemDeptLogic = new SystemDeptLogic(); parent::__construct(); } /** * 数据列表 * @param Request $request * @return Response */ public function index(Request $request): Response { $where = $request->more([ ['main_id', ''], ['name', ''], ['os', ''], ['status', ''], ]); $list = $this->logic->getIndex($where); return $this->success($list); } /** * 添加游戏 */ public function addGame(Request $request): Response { $data = $request->post(); $cp_callback_type = $data['cp_callback_type']; if($cp_callback_type == 1){ // 读取主游戏的KEY if(!$data['main_game_id']){ return $this->fail('请选择主游戏'); } $main_game_info = $this->logic->read($data['main_game_id']); $data['appkey'] = $main_game_info['appkey']; $data['login_key'] = $main_game_info['login_key']; $data['pay_key'] = $main_game_info['pay_key']; }else{ // 生成新的KEY $data['appkey'] = md5('appkey'.uniqid()); $data['login_key'] = md5('login_key'.uniqid()); $data['pay_key'] = md5('pay_key'.uniqid()); } $this->logic->add($data); return $this->success(); } /** * 更新游戏 */ public function updateGame(Request $request, $id): Response { $data = $request->post(); $game_info = $this->logic->read($id); $cp_callback_type = $data['cp_callback_type']; $game_info_cp_callback_type = $game_info['cp_callback_type']; $main_game_id = $data['main_game_id']; $game_info_main_game_id = $game_info['main_game_id']; // 如果主游戏ID改变,并且游戏发货规则为1,则获取主游戏KEY if(($main_game_id !== $game_info_main_game_id) && $cp_callback_type===1){ $main_game_info = $this->logic->read($main_game_id); $data['appkey'] = $main_game_info['appkey']; $data['login_key'] = $main_game_info['login_key']; $data['pay_key'] = $main_game_info['pay_key']; $this->logic->edit($id,$data); }else if($cp_callback_type !== $game_info_cp_callback_type){ // 如果游戏发货规则改变,则根据规则生成新的KEY if($cp_callback_type == 0){ // 如果是独立KEY, 则生成新的KEY $data['appkey'] = md5('appkey'.uniqid()); $data['login_key'] = md5('login_key'.uniqid()); $data['pay_key'] = md5('pay_key'.uniqid()); }else{ // 如果是主游戏KEY, 则获取主游戏KEY $appkey = $this->logic->read($main_game_id)['appkey']; $login_key = $this->logic->read($main_game_id)['login_key']; $pay_key = $this->logic->read($main_game_id)['pay_key']; $data['appkey'] = $appkey; $data['login_key'] = $login_key; $data['pay_key'] = $pay_key; } } $this->logic->edit($id, $data); return $this->success(); } /** * 设置部门游戏权限 */ public function setGameListByDeptId(Request $request): Response { $game_list = $request->post('game_list'); $dept_id = $request->post('dept_id'); $this->logic->setGameListByDeptId($dept_id, $game_list); return $this->success(); } }