SettingService.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace addons\ElectronCoupon\common\services;
  3. use common\services\mall\BaseAdsSettingService;
  4. use addons\ElectronCoupon\common\enums\ElectronCouponEnums;
  5. use yii\helpers\Json;
  6. /**
  7. * 设置配置服务
  8. * @package addons\ElectronCoupon\common\services
  9. */
  10. class SettingService extends BaseAdsSettingService
  11. {
  12. /**
  13. * @return array
  14. */
  15. public function defaultSetting(): array
  16. {
  17. return [
  18. 'images' => [],
  19. 'goods_list' => [],
  20. ];
  21. }
  22. /**
  23. * @return string
  24. */
  25. public function getAddosName(): string
  26. {
  27. return ElectronCouponEnums::ADDONS_NAME;
  28. }
  29. /**
  30. * @param array $setting
  31. * @return array
  32. */
  33. public function beforeGetSetting(array $setting): array
  34. {
  35. !is_array($setting['images']) && $setting['images'] = !empty($setting['images']) ? Json::decode($setting['images']) : [];
  36. !is_array($setting['goods_list']) && $setting['goods_list'] = !empty($setting['goods_list']) ? Json::decode($setting['goods_list']) : [];
  37. return $setting;
  38. }
  39. }