| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- // +----------------------------------------------------------------------
- // | EasyAdmin
- // +----------------------------------------------------------------------
- // | PHP交流群: 763822524
- // +----------------------------------------------------------------------
- // | 开源协议 https://mit-license.org
- // +----------------------------------------------------------------------
- // | github开源项目:https://github.com/zhongshaofa/EasyAdmin
- // +----------------------------------------------------------------------
- namespace app\admin\controller\system;
- use app\common\model\SystemConfig;
- use app\admin\service\TriggerService;
- use app\common\controller\AdminController;
- use EasyAdmin\annotation\ControllerAnnotation;
- use EasyAdmin\annotation\NodeAnotation;
- use services\CacheServices;
- use think\App;
- use think\facade\Db;
- /**
- * Class Config
- * @package app\admin\controller\system
- * @ControllerAnnotation(title="系统配置管理")
- */
- class Config extends AdminController
- {
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->model = new SystemConfig();
- }
- /**
- * @NodeAnotation(title="列表")
- */
- public function index()
- {
- $this->assign('total_renwu', 11);
- $this->assign('total_shouxu', 22);
- return $this->fetch();
- }
- /**
- * @NodeAnotation(title="保存")
- */
- public function save()
- {
- $this->checkPostRequest();
- $post = $this->request->post();
- sr_log(json_encode($post));
- // if (isset($post['xz_min_money'])){
- // if ($post['xz_min_money'] > $post['xz_max_money']){
- // return $this->error('最高级不能小于最低价');
- // }
- // if (!($post['xz_cur_money'] < $post['xz_max_money'] && $post['xz_cur_money'] > $post['xz_min_money'])){
- // return $this->error('当前价必须在区间之间');
- // }
- // }
- try {
- // if (isset($post['xz_cur_money'])){
- // // 清空所有商品详情缓存
- // $list = Db::name('shop_goods')->where('goods_type', 5)->field('goods_id,goods_sn')->select()->toArray();
- // foreach ($list as $key=>$val){
- // CacheServices::clearToken(md5('goodsDetail_' . $val['goods_sn']));
- // }
- //
- // }
- foreach ($post as $key => $val) {
- $this->model
- ->where('name', $key)
- ->update([
- 'value' => $val,
- ]);
- }
- TriggerService::updateMenu();
- TriggerService::updateSysconfig();
- } catch (\Exception $e) {
- $this->error('保存失败');
- }
- $this->success('保存成功');
- }
- }
|