gameupdate.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * 热更新相关
  4. */
  5. class ModelGameupdate
  6. {
  7. private $gu_updateurl = array(
  8. 1 => 'https://play.google.com/store/apps/details?id=',
  9. 2 => 'https://itunes.apple.com/us/app/%E0%B9%84%E0%B8%9E-%E0%B9%80%E0%B8%97-%E0%B8%81%E0%B8%8B-%E0%B8%AA%E0%B8%8B-%E0%B9%80%E0%B8%9B%E0%B8%AD%E0%B8%A3/id1267293867?l=zh&ls=1&mt=8',
  10. );
  11. private $gu_commonurl = array(
  12. 1 => 'https://play.google.com/store/apps/details?id=',
  13. 2 => 'itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=1267293867',
  14. );
  15. private $gu_hotfix = array(
  16. 1 => 'https://spin.gworldtek.com/public/hotupdatefile/android/',
  17. 2 => 'https://spin.gworldtek.com/public/hotupdatefile/ios/',
  18. );
  19. private $hw_commonurl = 'https://appgallery.cloud.huawei.com/uowap/index.html#/detailApp/C100440289';
  20. private $hw_updateurl = 'https://appgallery.cloud.huawei.com/uowap/index.html#/detailApp/C100440289';
  21. public function __construct()
  22. {
  23. }
  24. /**
  25. * 获取评论地址
  26. */
  27. public function getCommentUrl($device = 1, $sid = 1)
  28. {
  29. if( file_exists(WWWROOT.'config/config.sids.php') ){
  30. include WWWROOT.'config/config.sids.php';
  31. }
  32. if($device == 1) {//设备是安卓
  33. $packageName = $config['packageName'][$sid] ?? '';
  34. $url = empty($packageName) ? $this->gu_commonurl[1].'=com.superant.superpoker.th2' : $this->gu_commonurl[1].$packageName;
  35. }else {
  36. $url = $this->gu_commonurl[2];
  37. }
  38. return $url;
  39. }
  40. /**
  41. * 获取sid类型列表
  42. * @param int $type 1 安卓 2 苹果
  43. * @return array
  44. */
  45. public function getSidTypeList($type = 1)
  46. {
  47. if( file_exists(WWWROOT.'config/config.sids.php') ){
  48. include WWWROOT.'config/config.sids.php';
  49. }
  50. if($type == 1) {
  51. return $config['androidSidList'] ?? [];
  52. }else {
  53. return $config['iosSidList'] ?? [];
  54. }
  55. }
  56. public function createEmptyFlist()
  57. {
  58. $dir = '/data/texas/hotupdatefile';
  59. for($i = 1; $i < 3; $i++){
  60. for($j = 0; $j < 10; $j++){
  61. for($k = 0; $k < 10; $k++){
  62. $gu_version = $i.'.'.$j.'.'.$k;
  63. $anFilePath = "$dir/android/flist$gu_version";
  64. $iosFilePath = "$dir/ios/flist$gu_version";
  65. if(!file_exists( $anFilePath )){
  66. shell_exec(" cp $dir/android/flistempty $anFilePath ");
  67. }
  68. if(!file_exists( $iosFilePath )){
  69. shell_exec(" cp $dir/ios/flistempty $iosFilePath ");
  70. }
  71. }
  72. }
  73. }
  74. return true;
  75. }
  76. public function getGameUpdateHotfix($sid, $version){
  77. $hotFix = oo::commonOprRedis('server')->get(okeys::GameUpdateHotFix($sid, $version));
  78. if(!empty($hotFix)){
  79. return json_decode($hotFix,true);
  80. }
  81. $device = [
  82. 1=>'android',
  83. 2=>'ios',
  84. ];
  85. $device = $device[$sid];
  86. $tb = otable::gameupdate();
  87. $sql = " SELECT * FROM {$tb} WHERE gu_version like '%{$version}%' AND gu_device='{$device}' LIMIT 1 ";
  88. $ret = oo::commonOprDb('admin')->getOne($sql,MYSQLI_ASSOC);
  89. if(!empty($ret)){
  90. $tb = otable::GameHotFix();
  91. $sql = " SELECT * FROM {$tb} WHERE id='{$ret['id']}' ORDER BY version DESC LIMIT 1 ";
  92. $ret = oo::commonOprDb('admin')->getOne($sql,MYSQLI_ASSOC);
  93. if(!empty($ret)){
  94. $hotFix = [
  95. 'version'=>$ret['version'],
  96. 'isForce'=>$ret['isForce'],
  97. ];
  98. oo::commonOprRedis('server')->setex(okeys::GameUpdateHotFix($sid, $version),json_encode($hotFix,JSON_NUMERIC_CHECK),oo::redisRandomExpire(7*86400));
  99. return $hotFix;
  100. }
  101. }
  102. $hotFix = [
  103. 'version'=>$version,
  104. 'isForce'=>0,
  105. ];
  106. oo::commonOprRedis('server')->setex(okeys::GameUpdateHotFix($sid, $version),json_encode($hotFix,JSON_NUMERIC_CHECK),oo::redisRandomExpire(7*24*60*60));
  107. return $hotFix;
  108. }
  109. }