ChargeController.php 2.5 KB
<?php
/**
 * Created by PhpStorm.
 * User: yhbr
 * Date: 2018/8/30
 * Time: 14:29
 */
namespace app\admin\controller;
use cmf\controller\AdminBaseController;
use think\Db;

class ChargeController extends AdminBaseController {

    /**
     * 普通充值
     */
    public function commonCharge() {
        return $this->fetch('', [
            'list'  =>  Db::name('charge')->where(['is_bonus'=>0,'is_on_sale'=>1])->select()
        ]);
    }

    /**
     * 活动专享
     */
    public function bonusCharge() {
        return $this->fetch('', [
            'list'  =>  Db::name('charge')->where(['is_bonus'=>1,'is_on_sale'=>1])->select()
        ]);
    }

    public function commonChargeAdd() {
        $request=request();
        if($request->isPost()) {
            if(Db::name('charge')->insert($request->param())) {
                $this->success('添加成功');
            }else {
                $this->error('添加失败');
            }
        }else {
            return $this->fetch();
        }
    }

    public function commonChargeEdit() {
        $request=request();
        if($request->isPost()) {
            if(Db::name('charge')->update($request->param())) {
                $this->success('编辑成功');
            }else {
                $this->error('您为做出任何修改');
            }
        }else {
            return $this->fetch('', [
                'info'  =>  Db::name('charge')->where(['id'=>$request->param('id')])->find()
            ]);
        }
    }

    public function chargeDel() {
        $id=request()->param('id');
        if(Db::name('charge')->delete($id)) {
            $this->success('删除成功');
        }else {
            $this->error('删除失败');
        }
    }

    public function bonusChargeAdd() {
        $request=request();
        if($request->isPost()) {
            if(Db::name('charge')->insert($request->param())) {
                $this->success('添加成功');
            }else {
                $this->error('添加失败');
            }
        }else {
            return $this->fetch();
        }
    }

    public function bonusChargeEdit() {
        $request=request();
        if($request->isPost()) {
            if(Db::name('charge')->update($request->param())) {
                $this->success('编辑成功');
            }else {
                $this->error('您为做出任何修改');
            }
        }else {
            return $this->fetch('', [
                'info'  =>  Db::name('charge')->where(['id'=>$request->param('id')])->find()
            ]);
        }
    }



}