ConfigController.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace addons\TinyShop\api\modules\v1\controllers\common;
  3. use Yii;
  4. use yii\data\ActiveDataProvider;
  5. use api\controllers\OnAuthController;
  6. /**
  7. * 公用配置
  8. *
  9. * Class ConfigController
  10. * @package addons\TinyShop\api\modules\v1\controllers\common
  11. * @author jianyan74 <751393839@qq.com>
  12. */
  13. class ConfigController extends OnAuthController
  14. {
  15. public $modelClass = '';
  16. /**
  17. * 不用进行登录验证的方法
  18. *
  19. * 例如: ['index', 'update', 'create', 'view', 'delete']
  20. * 默认全部需要验证
  21. *
  22. * @var array
  23. */
  24. protected $authOptional = ['index'];
  25. /**
  26. * @return array|ActiveDataProvider
  27. */
  28. public function actionIndex()
  29. {
  30. $merchant_id = Yii::$app->services->merchant->getAutoId();
  31. $config = Yii::$app->services->addonsConfig->findConfigByCache('TinyShop', $merchant_id, true);
  32. foreach ($config as &$item) {
  33. is_numeric($item) && $item = (int)$item;
  34. }
  35. return [
  36. 'config' => $config,
  37. ];
  38. }
  39. /**
  40. * 获取基本配置
  41. *
  42. * @param int $merchant_id
  43. * @return string[]
  44. */
  45. public function actionBase(int $merchant_id)
  46. {
  47. $config = Yii::$app->services->config->merchantConfigAll(false, $merchant_id);
  48. return [
  49. 'wechat_mp_app_id' => $config['wechat_mp_app_id'] ?? '',
  50. ];
  51. }
  52. }
粤ICP备19079148号