123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace app\admin\controller\commission;
- use app\common\controller\Backend;
- use app\common\Service\ShopConfigService;
- use think\exception\PDOException;
- use think\exception\ValidateException;
- /**
- * 分销配置管理
- *
- * @icon fa fa-cogs
- */
- class Config extends Backend
- {
- /**
- * Config模型对象
- *
- */
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- }
- /**
- * 查看分销配置
- */
- public function index()
- {
- // 获取分销配置
- $commissionConfig = ShopConfigService::getConfigs('shop.commission');
- $this->view->assign('commissionConfig', $commissionConfig ?: []);
- return $this->view->fetch();
- }
-
- /**
- * 编辑配置
- */
- public function edit($ids = null)
- {
- if ($this->request->isPost()) {
- $this->token();
- $params = $this->request->post("row/a", [], 'trim');
-
- if ($params) {
- // try {
- // 特殊处理某些配置项
- if (isset($params['become_agent']) && is_array($params['become_agent'])) {
- $params['become_agent'] = json_encode($params['become_agent'], JSON_UNESCAPED_UNICODE);
- }
- // 更新配置
- ShopConfigService::setConfigs('shop.commission', $params);
- $this->success('配置保存成功');
- // } catch (ValidateException $e) {
- // $this->error($e->getMessage());
- // } catch (PDOException $e) {
- // $this->error($e->getMessage());
- // } catch (\Exception $e) {
- // $this->error($e->getMessage());
- // }
- }
- $this->error(__('Parameter %s can not be empty', ''));
- }
- }
- }
|