Payment.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\store\controller\setting;
  13. use think\response\Json;
  14. use app\store\controller\Controller;
  15. use app\store\model\Payment as PaymentModel;
  16. /**
  17. * 商城支付方式配置
  18. * Class Payment
  19. * @package app\store\controller
  20. */
  21. class Payment extends Controller
  22. {
  23. /**
  24. * 获取支付配置选项
  25. * @return Json
  26. * @throws \think\db\exception\DataNotFoundException
  27. * @throws \think\db\exception\DbException
  28. * @throws \think\db\exception\ModelNotFoundException
  29. */
  30. public function options(): Json
  31. {
  32. $options = PaymentModel::getAll($this->storeId);
  33. return $this->renderSuccess(compact('options'));
  34. }
  35. /**
  36. * 更新支付配置
  37. * @return Json
  38. */
  39. public function update(): Json
  40. {
  41. $model = new PaymentModel;
  42. if ($model->updateOptions($this->postForm())) {
  43. return $this->renderSuccess('更新成功');
  44. }
  45. return $this->renderError($model->getError() ?: '更新失败');
  46. }
  47. }