| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- /**
- * 检测客户端游戏更新
- */
- namespace app\api\controller\v1;
- use app\api\controller\Api;
- use app\common\model\SdkGameList;
- use app\common\model\Game;
- class CheckUpdate extends Api
- {
- protected $sdkGameListModel;
- protected $gameModel;
- public function _initialize()
- {
- parent::_initialize();
- $this->sdkGameListModel = new SdkGameList;
- $this->gameModel = new Game;
- }
- /**
- * IOS-热更新
- */
- public function checkClientUpdate()
- {
- $gameId = $this->input('gameid'); //游戏ID
- $channelId = $this->input('channel_id'); //渠道ID
- $channelVersion = $this->input('channel_version'); // 游戏版本构造号
- $checkResult = $this->validate($this->input,
- [
- ['gameid', 'require|integer', '游戏id不能为空|游戏ID必须为整型'],
- ['channel_id', 'require|integer', '渠道ID不能为空|渠道ID必须为整型'],
- ['channel_version', 'require|integer|egt:0', '游戏版本构造号不能为空|游戏版本构造号必须为整型|游戏版本构造号必须为大于等于0的整型'],
- ]);
- if (true !== $checkResult) {
- $this->jsonResult('', 0, $checkResult);
- }
- $where =[
- 'gameid' => $gameId,
- 'channel_id' => $channelId,
- 'upload_status' => 1
- ];
- $sdkgameInfo = $this->sdkGameListModel->where($where)->field('filename, channel_version')->find();
- $gameInfo = $this->gameModel->where(['id' => $gameId])->field('channel_version, pinyin')->find();
- $short_link = '';
- $update = false;
- if($channelVersion < $gameInfo['channel_version'] && $sdkgameInfo['channel_version'] >= $gameInfo['channel_version']){
- $short_link = db('nw_promotion_short_link')->where(['game_id'=>$gameId,'channel_id'=>$channelId,'package_type'=>0, 'type' => 1])->value('short_link');
- if (!empty($short_link)) {
- $short_link = T_DOMAIN.'/'.$short_link;
- $update = true;
- }
- }
- $data = [
- 'status' => $update,
- 'url' => $short_link,
- ];
- $this->jsonResult($data , 1, '请求成功!');
- }
- /**
- * 安卓sdk版本(热更)
- */
- public function version()
- {
- $sdkModel = model('common/AndroidSdk');
- $sdkInfo = $sdkModel->getLastVersionInfo();
- if (! empty($sdkInfo)) {
- $sdkInfo['status'] = true; // 默认需要强更
- $sdkInfo['filename'] = STATIC_DOMAIN.$sdkInfo['filename'];
- $this->jsonResult($sdkInfo, 1);
- } else {
- $this->jsonResult([], 0, '版本不存在');
- }
- }
- public function setting(){
- $this->jsonResult([], 0, '获取成功');
- }
- }
|