InitService.php 790 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace addons\Community\common\service;
  3. use addons\Community\common\enums\CommunityEnum;
  4. use common\models\common\Region;
  5. use yii\helpers\Json;
  6. class InitService
  7. {
  8. /**
  9. * @param int $mall_id
  10. * @return void
  11. */
  12. public static function init(int $mall_id)
  13. {
  14. $config = (new SettingService())->get($mall_id);
  15. if (empty($config) || empty($config['area']) || $config['area'] == '[]') {
  16. $regionIds = Region::find()->where(['level' => [1,2,3]])
  17. ->select('id')
  18. ->orderBy('id asc')
  19. ->column();
  20. \Yii::$app->services->setting->addons->set($mall_id, CommunityEnum::ADDONS_NAME, ['basic' => [
  21. 'area' => Json::encode($regionIds)
  22. ]]);
  23. }
  24. }
  25. }