AiAssistant.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\api\controller\v2;
  3. use app\api\controller\Api;
  4. use app\common\model\Setting;
  5. use think\Db;
  6. // AI助手
  7. class AiAssistant extends Api
  8. {
  9. // 参数配置
  10. public function getConfig()
  11. {
  12. $game_id = $this->input('gameid');
  13. $channel_id = $this->input('member_channel_id'); // 渠道ID(当前账户所属渠道)
  14. $result = [
  15. 'status' => 2, // 状态:1=开启, 2=关闭
  16. 'ai_url' => "", // AI助手URL
  17. ];
  18. if(empty($game_id) || empty($channel_id)){
  19. $this->jsonResult($result, 0, '当前游戏或渠道的AI助手未开启!');
  20. }
  21. $ai_status = Db::table('cy_gameinfo')->where('game_id', $game_id)->value('ai_status');
  22. if($ai_status == 3){
  23. $this->jsonResult($result, 1, '当前游戏的助手未开启!');
  24. } else if($ai_status == 2){
  25. $aiChannelInfo = Db::table('cy_game_ai_channel')->where(['game_id' => $game_id, 'channel_id' => $channel_id])->count();
  26. if($aiChannelInfo <= 0){
  27. $this->jsonResult($result, 1, '当前渠道的助手未开启!');
  28. }
  29. }
  30. $assistantUrl = Db::table('cy_setting')->where(['name' => 'ai_assistant_url'])->value('value');
  31. if($assistantUrl && $assistantUrl !== 0){
  32. $result['ai_url'] = $assistantUrl;
  33. }
  34. $result['status'] = 1;
  35. $this->jsonResult($result, 1, '助手开启!');
  36. }
  37. }