Autopack.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * 聚合sdk自动打包脚本获取客户端参数
  4. * User: Administrator
  5. * Date: 2020/4/3
  6. * Time: 17:32
  7. */
  8. namespace app\admin\controller;
  9. use think\Request;
  10. use app\common\model\Polychannel;
  11. use app\common\model\PolychannelGame;
  12. class Autopack extends Admin{
  13. protected $_gameKey = 'ab6D4b2eMjfKfI5A76DFbSflYH9VxCEuQ6Q';
  14. protected $_debug = false;
  15. public function _initialize()
  16. {
  17. }
  18. /**
  19. * 根据游戏拼音获取游戏信息
  20. */
  21. public function getGameInfo()
  22. {
  23. if (!$this->request->isPost()) $this->jsonResult('',0,'请求发生错误');;
  24. $param = Request::instance()->param();
  25. if ( !isset($param['pinyin']) || !isset($param['channel']) || !isset($param['sign'])) {
  26. $this->jsonResult('',0,'参数错误');
  27. }
  28. $sign = md5(strtolower($param['channel']. $param['pinyin'] . $this->_gameKey));
  29. if ($sign != $param['sign']) {
  30. $this->jsonResult('',0,'参数不合法');
  31. }
  32. if (!$this->_debug){
  33. $polychannelGameModel = new PolychannelGame;
  34. $polychannelModel = new Polychannel;
  35. $info = $polychannelGameModel->table('cy_polychannel_game cg,nw_channel c,cy_game g')
  36. ->field('cg.*,g.name game_name,c.name channel_name')
  37. ->where('cg.channel_id=c.id and g.id=cg.game_id')
  38. ->where(['g.pinyin'=>$param['pinyin'],'c.mark'=>$param['channel']])
  39. ->find();
  40. if(empty($info)){
  41. $this->jsonResult('',0,'聚合渠道游戏信息不存在');
  42. }
  43. //参数字段
  44. $param_field_arr = $polychannelModel->field('field_client')->where(['channel_id'=>$info['channel_id']])->find();
  45. if (empty($param_field_arr)) {
  46. $this->jsonResult('',0,'游戏信息不存在');
  47. }
  48. $field_client = $param_field_arr['field_client'];
  49. $field_client = (!empty($field_client) ? explode(';',$field_client) : $field_client);
  50. $arrParamClient = (!empty($info['param_client']) ? unserialize($info['param_client']) : $info['param_client']);
  51. }else{
  52. $field_client = 'channel;gameid;sign';
  53. $field_client = (!empty($field_client) ? explode(';',$field_client) : $field_client);
  54. $arrParamClient = [$param['channel'],$param['pinyin'],$param['sign']];
  55. }
  56. $data = [];
  57. foreach ($field_client as $k =>$v){
  58. $data[$v] = $arrParamClient[$k];
  59. }
  60. $this->jsonResult($data,1);
  61. }
  62. }