120 lines
3.2 KiB
PHP
120 lines
3.2 KiB
PHP
<?php
|
||
|
||
namespace app\channel\controller;
|
||
|
||
use think\admin\Controller;
|
||
use app\channel\service\ShopService;
|
||
|
||
/**
|
||
* 渠道店铺管理
|
||
* Class ChannelProduct
|
||
* @package app\channel\controller
|
||
*/
|
||
class ChannelShop extends Controller
|
||
{
|
||
/**
|
||
* 绑定数据表
|
||
* @var string
|
||
*/
|
||
private $table = 'ChannelShop';
|
||
|
||
/**
|
||
* 渠道商品管理
|
||
* @auth true
|
||
* @menu true
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
*/
|
||
public function index()
|
||
{
|
||
$this->title = '渠道店铺管理';
|
||
$query = $this->_query($this->table);
|
||
$query->like('name')->equal('status,cid')->dateBetween('create_at');
|
||
$query->where(['is_deleted' => 0])->order('cid desc, id desc')->page();
|
||
}
|
||
|
||
/**
|
||
* 数据列表处理
|
||
* @param array $data
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
*/
|
||
protected function _page_filter(&$data)
|
||
{
|
||
$this->cates = $this->app->db->name('ChannelList')->where(['is_deleted' => 0])->select();
|
||
foreach ($data as &$vo) {
|
||
$vo['channel_name'] = $this->app->db->name('ChannelList')->where(['id' => $vo['cid']])->value('name');
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 表单数据处理
|
||
* @param array $data
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
*/
|
||
protected function _form_filter(&$data)
|
||
{
|
||
$this->channels = $this->app->db->name('ChannelList')->where(['is_deleted' => 0])->select();
|
||
if ($this->request->isPost()) {
|
||
if (empty($data['name'])) $this->error('店铺名称不能为空!');
|
||
if (empty($data['shop_id'])) $this->error('店铺ID不能为空!');
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 添加渠道商品
|
||
* @auth true
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
*/
|
||
public function add()
|
||
{
|
||
$this->_form($this->table, 'form');
|
||
}
|
||
|
||
/**
|
||
* 编辑渠道商品
|
||
* @auth true
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
*/
|
||
public function edit()
|
||
{
|
||
$this->_form($this->table, 'form');
|
||
}
|
||
|
||
protected function _form_result($id, $data)
|
||
{
|
||
ShopService::instance()->get($id, false);
|
||
}
|
||
|
||
/**
|
||
* 修改渠道商品状态
|
||
* @auth true
|
||
* @throws \think\db\exception\DbException
|
||
*/
|
||
public function state()
|
||
{
|
||
$this->_save($this->table, $this->_vali([
|
||
'status.in:0,1' => '状态值范围异常!',
|
||
'status.require' => '状态值不能为空!',
|
||
]));
|
||
}
|
||
|
||
/**
|
||
* 删除渠道商品
|
||
* @auth true
|
||
* @throws \think\db\exception\DbException
|
||
*/
|
||
public function remove()
|
||
{
|
||
$this->_delete($this->table);
|
||
}
|
||
|
||
} |