91 lines
2.8 KiB
PHP
91 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace addon\ali1688\shop\controller;
|
|
|
|
use addon\ali1688\model\Choice;
|
|
use addon\ali1688\model\Template as TemplateModel;
|
|
use app\model\goods\GoodsCategory as GoodsCategoryModel;
|
|
use app\shop\controller\BaseShop;
|
|
use app\model\express\ExpressTemplate;
|
|
|
|
class Template extends BaseShop
|
|
{
|
|
private $templateModel;
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->templateModel = new TemplateModel($this->site_id);
|
|
}
|
|
|
|
public function lists()
|
|
{
|
|
if (request()->isAjax()) {
|
|
// 参数获取
|
|
$search = request()->all();
|
|
$search['site_id'] = $this->site_id;
|
|
return $this->templateModel->getTemplateList($search);
|
|
}
|
|
$this->forthMenu();
|
|
return $this->fetch("template/lists");
|
|
}
|
|
|
|
public function add()
|
|
{
|
|
if (request()->isAjax()) {
|
|
// 参数获取
|
|
$data = request()->all();
|
|
$data['site_id'] = $this->site_id;
|
|
$data['create_time'] = time();
|
|
return $this->templateModel->addTemplate($data);
|
|
}
|
|
$this->get_list();
|
|
return $this->fetch("template/add");
|
|
}
|
|
|
|
public function get_list()
|
|
{
|
|
//获取一级商品分类
|
|
$goods_category_model = new GoodsCategoryModel();
|
|
$condition = [
|
|
['pid', '=', 0],
|
|
['site_id', '=', $this->site_id]
|
|
];
|
|
$goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate')['data'];
|
|
$this->assign("goods_category_list", $goods_category_list);
|
|
$express_template_model = new ExpressTemplate();
|
|
$condition = array(
|
|
['site_id', "=", $this->site_id],
|
|
);
|
|
$express_template_list = $express_template_model->getExpressTemplatePageList($condition);
|
|
$this->assign("express_template_list", $express_template_list['data']['list']);
|
|
$this->assign('goods_class', array_column(event('GoodsClass'), null, 'goods_class'));
|
|
}
|
|
|
|
public function edit()
|
|
{
|
|
$data = request()->all();
|
|
if (!isset($data['id']) && !intval($data['id'])) {
|
|
return $this->error('模板ID错误');
|
|
}
|
|
if (request()->isAjax()) {
|
|
$data['update_time'] = time();
|
|
return $this->templateModel->editTemplate($data);
|
|
}
|
|
$data = $this->templateModel->templateInfo($data['id']);
|
|
$this->assign('data', $data);
|
|
$this->get_list();
|
|
return $this->fetch("template/edit");
|
|
}
|
|
|
|
public function del()
|
|
{
|
|
$data = request()->all();
|
|
if (!isset($data['id']) && !intval($data['id'])) {
|
|
return $this->error('模板ID错误');
|
|
}
|
|
if (request()->isAjax()) {
|
|
return $this->templateModel->delTemplate($data['id']);
|
|
}
|
|
}
|
|
} |