iwebshop插件的操作

<?php
class Miao extends pluginBase
{
    //插件名字
    public static function name(){
        return "秒杀";
    }
    //插件介绍
    public static function description(){
        return "运用此插件吸引顾客,设置限时抢购。";
    }

    //新建数据库
    public static function install(){
        $miao = new IModel('miao');
        if($miao->exists()){
            return true;
        }
        //建立表
        $data = array(
            "comment" => self::name(),
            "column"  => array(
                "id" => array("type" => "int(11) unsigned",'auto_increment' => 1),
                "biao" => array("type" => "varchar(100)","comment" => "标题"),
                "forea_time" => array("type" => "varchar(80)","comment"=>"秒杀开始时间"),
                "end_time" => array("type" => "varchar(80)","comment"=>"秒杀结束时间"),
                "jia" => array("type" => "varchar(20)","comment" => "价格"),
                "num" => array("type" => "varchar(20)","comment" => "数量"),
                "desc" => array("type" => "text","comment" => "描述"),
                "goods_id"=>array("type"=>"int(11) unsigned"),
            ),
            "index" => array("primary" => "id"),
        );
        $miao->setData($data);
        return $miao->createTable();
    }
    //卸载数据表
    public static function uninstall()
    {
        $ppt = new IModel('miao');
        return $ppt->dropTable();
    }
    //钩子(显示到模块上)
    public function reg(){
        plugin::reg("onSystemMenuCreate", function () {
            Menu::$menu['营销']['营销活动']['/plugins/seckill_list']=$this->name();
        });
        plugin::reg("onBeforeCreateAction@plugins@seckill_list", function () {
            self::controller()->seckill_list = function () {
                $this->seckill_list();
            };
        });
        plugin::reg("onBeforeCreateAction@plugins@seckill_edit", function () {
            self::controller()->seckill_edit = function () {
                $this->seckill_edit();
            };
        });
        plugin::reg("onBeforeCreateAction@plugins@seckilll_edit", function () {
            self::controller()->seckilll_edit = function () {
                $this->seckilll_edit();
            };
        });
        plugin::reg("onBeforeCreateAction@plugins@seckill_del", function () {
            self::controller()->seckill_del = function () {
                $this->seckill_del();
            };
        });
        plugin::reg("onBeforeCreateAction@plugins@seckill_upt", function () {
            self::controller()->seckill_upt = function () {
                $this->seckill_upt();
            };
        });
    }
    public function seckill_list(){
        $testObj = new IModel("miao");
        $arr = $testObj->query();
        $this->list = $arr;
        $this->redirect('seckill_list',$arr);
    }
    public function seckill_edit(){
        $this->redirect('seckill_edit');
    }
    public function seckilll_edit(){
        $is_close = IReq::get("is_close");              //是否开启

        if($is_close==0) {
            $goods_id = IReq::get("goods_id");                //商品id
            $biao = IReq::get("title");                        //标题
            $forea_time = IReq::get("start_time");            //开始时间
            $end_time = IReq::get("end_time");              //结束时间
            $desc = IReq::get("intro");                    //介绍
            $jia = IReq::get("regiment_price");            //秒杀价格
            $num = IReq::get("num");            //秒杀价格
            $arr = array(
                "biao" => $biao,
                "forea_time" => $forea_time,
                "end_time" => $end_time,
                "desc" => $desc,
                "jia" => $jia,
                "goods_id" => $goods_id,
                "num" => $num
            );
            $testObj = new IModel("miao");
            $testObj->setData($arr);
            $testObj->add();
            $this->seckill_list();
        }
    }
    public function seckill_del(){
        $id = IReq::get("id");
        $testObj = new IModel("miao");
        $testObj->del("id=$id");
        $this->seckill_list();
    }
    public function seckill_upt(){
        $testObj = new IModel("miao");
        $id = IFilter::act(IReq::get("id"), 'int');
        $arr = $testObj->query("id=$id");
        $this->list = $arr;
        $this->redirect('seckill_edit');
    }
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

A_青涩

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值