DistAdminDistributor.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. namespace App\Distributor\Repositories;
  3. use App\Models\DistAdminDistributor as Model;
  4. use Dcat\Admin\Repositories\EloquentRepository;
  5. class DistAdminDistributor extends EloquentRepository
  6. {
  7. /**
  8. * Model.
  9. *
  10. * @var string
  11. */
  12. protected $eloquentClass = Model::class;
  13. /*
  14. * 清缓存
  15. */
  16. public static function clearCache($timeOut = 2)
  17. {
  18. $domain = self::getDomain(1);
  19. $url = $domain . '/?__clear_cache=1';
  20. curlGet($url,$timeOut);
  21. }
  22. /*
  23. * 得到当前分销商的域名
  24. * type 0:当前域名 1:二级域名 2:自定义域名
  25. */
  26. public static function getDomain($type=0)
  27. {
  28. $distId = getDistributorId();
  29. $model = new Model();
  30. return $model->getDomain($distId,$type);
  31. }
  32. /*
  33. * 得到分销商信息
  34. */
  35. public static function getInfo()
  36. {
  37. $id = getDistributorId();
  38. $row = Model::find($id);
  39. return $row;
  40. }
  41. /*
  42. * 修改域名名称
  43. */
  44. public static function updateDomain($domainType,$customDomain)
  45. {
  46. $id = getDistributorId();
  47. $row = Model::find($id);
  48. $row->domain_type = $domainType;
  49. if ($domainType == 1) {
  50. $row->custom_domain = $customDomain;
  51. }
  52. $row->save();
  53. }
  54. public static function updateInfo($info)
  55. {
  56. $id = getDistributorId();
  57. $row = Model::find($id);
  58. $row->logo = $info['logo'];
  59. $row->site_name = $info['site_name'];
  60. $row->company_name = $info['company_name'];
  61. $row->company_address = $info['company_address'];
  62. $row->contact_number = $info['contact_number'];
  63. $row->service_hotline = $info['service_hotline'];
  64. $row->whats_app = $info['whats_app'];
  65. $row->facebook = $info['facebook'];
  66. $row->instagram = $info['instagram'];
  67. $row->youtube = $info['youtube'];
  68. $row->linkedin = $info['linkedin'];
  69. $row->tiktok = $info['tiktok'];
  70. $row->seo_title = $info['seo_title'];//seo_title
  71. $row->seo_keywords = $info['seo_keywords'];//seo_keywords
  72. $row->seo_description = $info['seo_description'];//seo_description
  73. $row->save();
  74. }
  75. /*
  76. * 分销商切换主题
  77. */
  78. public static function enableTheme($appearanceId)
  79. {
  80. $appearanceId = intval($appearanceId);
  81. $distId = getDistributorId();
  82. $distAppearance = new DistAppearance();
  83. $appearanceRow = $distAppearance->model()->find($appearanceId);
  84. if ($appearanceRow && $appearanceRow->enabled == 1) {
  85. //修改分销商主题
  86. $row = Model::find($distId);
  87. $row->appearance_id = $appearanceId;
  88. $row->save();
  89. //切换主题
  90. DistAppearance::switchTheme($appearanceId, $distId);
  91. return true;
  92. }
  93. return false;
  94. }
  95. }