UploadConfig.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use app\models\Option;
  9. use app\constants\OptionSetting;
  10. /**
  11. * This is the model class for table "{{%upload_config}}".
  12. *
  13. * @property integer $id
  14. * @property integer $store_id
  15. * @property string $storage_type
  16. * @property string $aliyun
  17. * @property string $qcloud
  18. * @property string $qiniu
  19. * @property integer $created_at
  20. * @property integer $is_delete
  21. */
  22. class UploadConfig extends \yii\db\ActiveRecord
  23. {
  24. /**
  25. * @inheritdoc
  26. */
  27. public static function tableName()
  28. {
  29. return '{{%upload_config}}';
  30. }
  31. /**
  32. * @inheritdoc
  33. */
  34. public function rules()
  35. {
  36. return [
  37. [['store_id'], 'required'],
  38. [['store_id', 'created_at', 'is_delete'], 'integer'],
  39. [['aliyun', 'qcloud', 'qiniu'], 'string'],
  40. [['storage_type'], 'string', 'max' => 255],
  41. ];
  42. }
  43. /**
  44. * @inheritdoc
  45. */
  46. public function attributeLabels()
  47. {
  48. return [
  49. 'id' => 'ID',
  50. 'store_id' => 'Store ID',
  51. 'storage_type' => '存储类型:留空=本地,aliyun=阿里云oss,qcloud=腾讯云cos,qiniu=七牛云存储',
  52. 'aliyun' => '阿里云oss配置,json格式',
  53. 'qcloud' => '腾讯云cos配置,json格式',
  54. 'qiniu' => '七牛云存储配置,json格式',
  55. 'created_at' => 'Addtime',
  56. 'is_delete' => 'Is Delete',
  57. ];
  58. }
  59. public static function getConf($store_id) {
  60. $mho = Option::get(OptionSetting::MCH_HIDE_OSS, 0, 'saas', 0)['value'];
  61. if($mho){
  62. $store_id = 0;
  63. }
  64. $config = UploadConfig::findOne(['store_id' => $store_id, 'is_delete' => 0]);
  65. if ($store_id > 0 && empty($config)) {
  66. $config = UploadConfig::findOne(['store_id' => 0, 'is_delete' => 0]);
  67. }
  68. \Yii::error([__METHOD__, $store_id]);
  69. return $config;
  70. }
  71. }