OutsideAppSetting.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Name: 芸众商城系统
  5. * Author: 广州市芸众信息科技有限公司
  6. * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
  7. * Date: 2022/1/6
  8. * Time: 17:01
  9. */
  10. namespace app\outside\modes;
  11. use app\common\models\BaseModel;
  12. use app\outside\services\OutsideAppService;
  13. class OutsideAppSetting extends BaseModel
  14. {
  15. protected $table = 'yz_outside_app_setting';
  16. protected $guarded = [];
  17. static protected $needLog = true;
  18. public $attributes = [];
  19. protected $casts = [
  20. 'value' => 'json',
  21. ];
  22. public static function current()
  23. {
  24. return self::uniacid()->first();
  25. }
  26. public static function uniqueApp()
  27. {
  28. $appId = OutsideAppService::createAppId();
  29. while (1) {
  30. if (!self::where('app_id', $appId)->first()) {
  31. break;
  32. }
  33. $appId = OutsideAppService::createAppId();
  34. }
  35. return $appId;
  36. }
  37. public static function uniqueSecret($appId = '')
  38. {
  39. $app_secret = OutsideAppService::createSecret($appId);
  40. while (1) {
  41. if (!self::where('app_secret', $app_secret)->first()) {
  42. break;
  43. }
  44. $app_secret = OutsideAppService::createSecret($appId);
  45. }
  46. return $app_secret;
  47. }
  48. }