|
@@ -0,0 +1,160 @@
|
|
|
+<?php
|
|
|
+namespace app\store\controller;
|
|
|
+use library\Controller;
|
|
|
+use think\Db;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 直播商品添加
|
|
|
+ * Class Goods
|
|
|
+ * @package app\store\controller
|
|
|
+ */
|
|
|
+class LiveGoods extends Controller
|
|
|
+{
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 绑定数据表
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ protected $table = 'StoreLiveGoods';
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 直播商品列表
|
|
|
+ * @auth true
|
|
|
+ * @menu true
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function index()
|
|
|
+ {
|
|
|
+ $this->title = '直播商品列表';
|
|
|
+ $this->cate_id = input('cate_id');
|
|
|
+ $goods_cate = Db::table('store_live_cate')
|
|
|
+ ->field('id,title')
|
|
|
+ ->where('status',1)
|
|
|
+ ->where('is_deleted',0)
|
|
|
+ ->order('sort desc , id desc')
|
|
|
+ ->select();
|
|
|
+ $this->goods_cate = array_column($goods_cate,null,'id');
|
|
|
+ $query = $this->_query($this->table)->where('is_deleted',0);
|
|
|
+ if($this->cate_id) $query->where('cate_id',$this->cate_id );
|
|
|
+ $query->like('name');
|
|
|
+ $query->order('status desc , sort desc , id desc')->page();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据列表处理
|
|
|
+ * @auth true
|
|
|
+ * @menu true
|
|
|
+ * @param array $data
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ protected function _index_page_filter(&$data)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加商品
|
|
|
+ * @auth true
|
|
|
+ * @menu true
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function add()
|
|
|
+ {
|
|
|
+ $this->title = '添加商品';
|
|
|
+ $this->goods_cate = Db::table('store_live_cate')
|
|
|
+ ->field('id,title')
|
|
|
+ ->where('status',1)
|
|
|
+ ->where('is_deleted',0)
|
|
|
+ ->order('sort desc , id desc')
|
|
|
+ ->select();
|
|
|
+ $this->_form($this->table, 'form');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑商品
|
|
|
+ * @auth true
|
|
|
+ * @menu true
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function edit()
|
|
|
+ {
|
|
|
+ $this->title = '编辑商品';
|
|
|
+ $this->goods_cate = Db::table('store_live_cate')
|
|
|
+ ->field('id,title')
|
|
|
+ ->where('status',1)
|
|
|
+ ->where('is_deleted',0)
|
|
|
+ ->order('sort desc , id desc')
|
|
|
+ ->select();
|
|
|
+ $this->_form($this->table, 'form');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 禁用
|
|
|
+ * @auth true
|
|
|
+ * @menu true
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function forbidden()
|
|
|
+ {
|
|
|
+ $this->_save($this->table, ['status' => '0']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 启用
|
|
|
+ * @auth true
|
|
|
+ * @menu true
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function enable()
|
|
|
+ {
|
|
|
+ $this->_save($this->table, ['status' => 1]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ * @auth true
|
|
|
+ * @menu true
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function del()
|
|
|
+ {
|
|
|
+ $this->_save($this->table, ['is_deleted' => 1]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 表单数据处理
|
|
|
+ * @auth true
|
|
|
+ * @menu true
|
|
|
+ * @param array $data
|
|
|
+ */
|
|
|
+ protected function _form_filter(&$data)
|
|
|
+ {
|
|
|
+ $data['create_at'] = date('Y-m-d H:i:s');
|
|
|
+ }
|
|
|
+
|
|
|
+}
|