WechatConfigController.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\modules\admin\controllers;
  8. use app\models\WechatConfig;
  9. use app\modules\admin\models\WechatConfigForm;
  10. class WechatConfigController extends BaseController
  11. {
  12. /**
  13. * 获取配置
  14. */
  15. public function actionConfig() {
  16. $form = new WechatConfigForm();
  17. $form->store_id = get_store_id();
  18. $form->type = get_params('type');
  19. return $this->asJson($form->getConfig());
  20. }
  21. /**
  22. * 存储配置
  23. */
  24. public function actionSave() {
  25. $store_id = get_store_id();
  26. $form = new WechatConfigForm();
  27. $model = WechatConfig::findOne(['store_id' => $store_id, 'type' => post_params('type')]);
  28. if (!$model) {
  29. $model = new WechatConfig();
  30. }
  31. $form->store_id = $store_id;
  32. $form->model = $model;
  33. $form->attributes = post_params();
  34. return $this->asJson($form->saveConfig());
  35. }
  36. }