SystemBroadcast.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\model\system;
  12. use traits\ModelTrait;
  13. use basic\ModelBasic;
  14. use service\AlipayDisposeService;
  15. /**
  16. * Class SystemBroadcast
  17. * @package app\admin\model\system
  18. */
  19. class SystemBroadcast extends ModelBasic
  20. {
  21. use ModelTrait;
  22. /**
  23. * 直播域名列表
  24. */
  25. public static function broadcastList()
  26. {
  27. $list=self::where('is_del',0)->order('id desc')->select();
  28. $list=count($list)>0 ? $list->toArray() : [];
  29. $array=[];
  30. foreach ($list as $key=>$value){
  31. if($value['domain_status']=='configuring'){
  32. $res=AlipayDisposeService::describeLiveDomainDetails($value['domain_name'],$value['region']);
  33. if(is_array($res) && array_key_exists('DomainDetail',$res)){
  34. self::where('is_del', 0)->where('id', $value['id'])->update(['cname' => $res['DomainDetail']['Cname'], 'domain_status' => $res['DomainDetail']['DomainStatus']]);
  35. array_push($array,$value);
  36. }else{
  37. continue;
  38. }
  39. }else{
  40. array_push($array,$value);
  41. }
  42. }
  43. return $array;
  44. }
  45. /**获取域名主KEY
  46. * @param string $domainName
  47. * @param string $regionId
  48. * @return mixed|null
  49. */
  50. public static function auth_key($domainName='',$regionId='')
  51. {
  52. $data=AlipayDisposeService::describeLiveDomainConfigs($domainName,$regionId);
  53. if(is_array($data) && array_key_exists('DomainConfigs',$data)){
  54. $FunctionArg=$data['DomainConfigs']['DomainConfig'][0]['FunctionArgs']['FunctionArg'];
  55. $auth_key=null;
  56. foreach ($FunctionArg as $k=>$vc){
  57. if($vc['ArgName']=='auth_key1'){
  58. $auth_key=$vc['ArgValue'];
  59. }
  60. }
  61. return $auth_key;
  62. }else{
  63. return false;
  64. }
  65. }
  66. /**
  67. * 保存存储空间
  68. * @param $list
  69. */
  70. public static function addBroadcast($data,$res1,$auth_key)
  71. {
  72. $data['add_time']=time();
  73. $data['auth_key1']=$auth_key;
  74. $data['cname']=$res1['DomainDetail']['Cname'];
  75. $data['domain_status']=$res1['DomainDetail']['DomainStatus'];
  76. $res=self::set($data);
  77. return $res;
  78. }
  79. }