其余文件
This commit is contained in:
125
app/admin/controller/goods/Brand.php
Normal file
125
app/admin/controller/goods/Brand.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\admin\controller\goods;
|
||||
|
||||
|
||||
use app\admin\logic\goods\BrandLogic;
|
||||
use app\admin\validate\goods\BrandValidate;
|
||||
use app\common\basics\AdminBase;
|
||||
use app\common\model\goods\GoodsBrand as GoodsBrandModel;
|
||||
use app\common\server\JsonServer;
|
||||
|
||||
|
||||
/**
|
||||
* 商品品牌
|
||||
* Class GoodsBrand
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Brand extends AdminBase
|
||||
{
|
||||
/**
|
||||
* Notes: 列表
|
||||
* @author 段誉(2021/4/15 10:49)
|
||||
* @return string|\think\response\Json
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$get = $this->request->get();
|
||||
return JsonServer::success('获取成功', BrandLogic::lists($get));
|
||||
}
|
||||
return view();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 添加
|
||||
* @author 段誉(2021/4/15 10:49)
|
||||
* @return string|\think\response\Json
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$post = $this->request->post();
|
||||
(new BrandValidate())->goCheck('add');
|
||||
if (BrandLogic::add($post)) {
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
return JsonServer::error(BrandLogic::getError() ?: '操作失败');
|
||||
}
|
||||
return view('', ['capital' => getCapital()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 编辑
|
||||
* @author 段誉(2021/4/15 10:49)
|
||||
* @return string|\think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$id = $this->request->get('id');
|
||||
if ($this->request->isAjax()) {
|
||||
$post = $this->request->post();
|
||||
(new BrandValidate())->goCheck('edit');
|
||||
if (BrandLogic::edit($post)) {
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
return JsonServer::error(BrandLogic::getError() ?: '操作失败');
|
||||
}
|
||||
return view('', [
|
||||
'detail' => GoodsBrandModel::find($id),
|
||||
'capital' => getCapital()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 删除
|
||||
* @author 段誉(2021/4/15 10:49)
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$id = $this->request->post('id');
|
||||
(new BrandValidate())->goCheck('del');
|
||||
if (BrandLogic::del($id)) {
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
return JsonServer::error(BrandLogic::getError() ?: '操作失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 切换状态
|
||||
* @author 段誉(2021/4/15 15:17)
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function switchStatus()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
GoodsBrandModel::update(['is_show' => $post['is_show']], ['id' => $post['id']]);
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
}
|
||||
142
app/admin/controller/goods/Category.php
Normal file
142
app/admin/controller/goods/Category.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\goods;
|
||||
|
||||
use app\common\basics\AdminBase;
|
||||
use app\admin\logic\goods\CategoryLogic;
|
||||
use app\admin\validate\goods\CategoryValidate;
|
||||
use think\exception\ValidateException;
|
||||
use app\common\server\JsonServer;
|
||||
use think\facade\View;
|
||||
|
||||
/**
|
||||
* 平台商品分类
|
||||
* Class Category
|
||||
* @package app\admin\controller\goods
|
||||
*/
|
||||
class Category extends AdminBase
|
||||
{
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$category_tree = CategoryLogic::lists();
|
||||
// reqData方式渲染
|
||||
$treeTableData = [
|
||||
'code' => 0,
|
||||
'msg' => '分类列表',
|
||||
'data' => json_encode($category_tree)
|
||||
];
|
||||
return json($treeTableData);
|
||||
}
|
||||
return view();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$post = $this->request->post();
|
||||
$post['del'] = 0;
|
||||
try {
|
||||
validate(CategoryValidate::class)->scene('add')->check($post);
|
||||
} catch (ValidateException $e) {
|
||||
return JsonServer::error($e->getError());
|
||||
}
|
||||
$res = CategoryLogic::add($post);
|
||||
if ($res) {
|
||||
return JsonServer::success('分类添加成功');
|
||||
} else {
|
||||
return JsonServer::error('分类添加失败');
|
||||
}
|
||||
}
|
||||
|
||||
$category_list = CategoryLogic::categoryTwoTree();
|
||||
return view('add', ['category_list' => $category_list]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
try {
|
||||
validate(CategoryValidate::class)->scene('del')->check($post);
|
||||
} catch (ValidateException $e) {
|
||||
return JsonServer::error($e->getError());
|
||||
}
|
||||
$res = CategoryLogic::del($post);
|
||||
if ($res) {
|
||||
return JsonServer::success('删除分类成功');
|
||||
} else {
|
||||
return JsonServer::error('删除分类失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$post = $this->request->post();
|
||||
$post['del'] = 0;
|
||||
try {
|
||||
validate(CategoryValidate::class)->scene('edit')->check($post);
|
||||
} catch (ValidateException $e) {
|
||||
return JsonServer::error($e->getError());
|
||||
}
|
||||
$res = CategoryLogic::edit($post);
|
||||
if ($res) {
|
||||
return JsonServer::success('编辑分类成功');
|
||||
} else {
|
||||
return JsonServer::error('编辑分类失败');
|
||||
}
|
||||
}
|
||||
|
||||
$id = $this->request->get('id');
|
||||
$detail = CategoryLogic::getCategory($id);
|
||||
$category_list = CategoryLogic::categoryTwoTree();
|
||||
return view('edit', [
|
||||
'detail' => $detail,
|
||||
'category_list' => $category_list
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改显示状态
|
||||
*/
|
||||
public function switchStatus()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$res = CategoryLogic::switchStatus($post);
|
||||
if ($res) {
|
||||
return JsonServer::success('修改成功');
|
||||
} else {
|
||||
return JsonServer::error('修改失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
122
app/admin/controller/goods/Column.php
Normal file
122
app/admin/controller/goods/Column.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\admin\controller\goods;
|
||||
|
||||
|
||||
use app\admin\logic\goods\ColumnLogic;
|
||||
use app\admin\validate\goods\ColumnValidate;
|
||||
use app\common\basics\AdminBase;
|
||||
use app\common\model\goods\GoodsColumn as GoodsColumnModel;
|
||||
use app\common\server\JsonServer;
|
||||
|
||||
|
||||
/**
|
||||
* 商品栏目
|
||||
* Class GoodsColumn
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Column extends AdminBase
|
||||
{
|
||||
/**
|
||||
* Notes: 列表
|
||||
* @author 段誉(2021/4/15 10:49)
|
||||
* @return string|\think\response\Json
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$get = $this->request->get();
|
||||
return JsonServer::success('获取成功', ColumnLogic::lists($get));
|
||||
}
|
||||
return view();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 添加
|
||||
* @author 段誉(2021/4/15 10:49)
|
||||
* @return string|\think\response\Json
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$post = $this->request->post();
|
||||
(new ColumnValidate())->goCheck('add');
|
||||
if (ColumnLogic::add($post)) {
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
return JsonServer::error(ColumnLogic::getError() ?: '操作失败');
|
||||
}
|
||||
return view();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 编辑
|
||||
* @author 段誉(2021/4/15 10:49)
|
||||
* @return string|\think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$id = $this->request->get('id');
|
||||
if ($this->request->isAjax()) {
|
||||
$post = $this->request->post();
|
||||
(new ColumnValidate())->goCheck('edit');
|
||||
if (ColumnLogic::edit($post)) {
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
return JsonServer::error(ColumnLogic::getError() ?: '操作失败');
|
||||
}
|
||||
return view('', ['detail' => GoodsColumnModel::find($id)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 删除
|
||||
* @author 段誉(2021/4/15 10:49)
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$id = $this->request->post('id');
|
||||
(new ColumnValidate())->goCheck('del');
|
||||
if (ColumnLogic::del($id)) {
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
return JsonServer::error(ColumnLogic::getError() ?: '操作失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 切换状态
|
||||
* @author 段誉(2021/4/15 15:17)
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function switchStatus()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
GoodsColumnModel::update(['status' => $post['status']],['id' => $post['id']]);
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
}
|
||||
48
app/admin/controller/goods/Comment.php
Normal file
48
app/admin/controller/goods/Comment.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace app\admin\controller\goods;
|
||||
|
||||
use app\admin\logic\goods\CommentLogic;
|
||||
use app\common\basics\AdminBase;
|
||||
use app\common\server\JsonServer;
|
||||
|
||||
class Comment extends AdminBase
|
||||
{
|
||||
/**
|
||||
* 评价列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if($this->request->isAjax()) {
|
||||
$get = $this->request->get();
|
||||
$data = CommentLogic::lists($get);
|
||||
return JsonServer::success('', $data);
|
||||
}
|
||||
return view();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示/隐藏商品评价
|
||||
*/
|
||||
public function changeStatus()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$result = CommentLogic::changeStatus($post);
|
||||
if($result === true) {
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
return JsonServer::error(CommentLogic::getError());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$result = CommentLogic::del($post);
|
||||
if($result === true) {
|
||||
return JsonServer::success('删除成功');
|
||||
}
|
||||
return JsonServer::error(CommentLogic::getError());
|
||||
}
|
||||
}
|
||||
226
app/admin/controller/goods/Goods.php
Normal file
226
app/admin/controller/goods/Goods.php
Normal file
@ -0,0 +1,226 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\admin\controller\goods;
|
||||
|
||||
use app\common\basics\AdminBase;
|
||||
use app\common\enum\GoodsEnum;
|
||||
use app\common\model\goods\GoodsBrand;
|
||||
use app\common\model\goods\GoodsUnit;
|
||||
use app\common\model\Freight;
|
||||
use app\common\model\goods\Supplier;
|
||||
use app\common\model\goods\Goods as GoodsModel;
|
||||
use app\common\server\JsonServer;
|
||||
use app\admin\logic\goods\CategoryLogic as MallCategoryLogic;
|
||||
use app\admin\logic\goods\GoodsLogic;
|
||||
use app\admin\logic\goods\ColumnLogic;
|
||||
use app\shop\logic\goods\CategoryLogic as ShopCategoryLogic;
|
||||
use think\exception\ValidateException;
|
||||
use app\admin\validate\goods\GoodsValidate;
|
||||
|
||||
/**
|
||||
* 商品管理
|
||||
* Class Goods
|
||||
*/
|
||||
class Goods extends AdminBase
|
||||
{
|
||||
/**
|
||||
* Notes: 列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$get = $this->request->get();
|
||||
return JsonServer::success('', GoodsLogic::lists($get));
|
||||
}
|
||||
|
||||
$cate_list = MallCategoryLogic::categoryTreeeTree();
|
||||
$statistics = GoodsLogic::statistics();
|
||||
$column_list = ColumnLogic::getList();
|
||||
return view('', [
|
||||
'statistics' => $statistics,
|
||||
'cate_list' => $cate_list,
|
||||
'column_list' => $column_list,
|
||||
'goods_type' => GoodsEnum::getTypeDesc()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function view()
|
||||
{
|
||||
$goods_id = $this->request->get('goods_id');
|
||||
$shop_id = GoodsModel::where('id', $goods_id)->value('shop_id');
|
||||
return view('goods/goods/add', [
|
||||
'category_lists' => json_encode(MallCategoryLogic::getAllTree(), JSON_UNESCAPED_UNICODE),
|
||||
'shop_category_lists' => json_encode(ShopCategoryLogic::listAll($shop_id), JSON_UNESCAPED_UNICODE),
|
||||
'brand_lists' => json_encode(GoodsBrand::getNameColumn(), JSON_UNESCAPED_UNICODE),
|
||||
'supplier_lists' => json_encode(Supplier::getNameColumn(), JSON_UNESCAPED_UNICODE),
|
||||
'unit_lists' => json_encode(GoodsUnit::getNameColumn(), JSON_UNESCAPED_UNICODE),
|
||||
'freight_lists' => json_encode(Freight::getNameColumn($shop_id), JSON_UNESCAPED_UNICODE),
|
||||
'info' => json_encode(GoodsLogic::info($goods_id), JSON_UNESCAPED_UNICODE)
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 违规重审
|
||||
*/
|
||||
public function reAudit()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
try {
|
||||
$params = $this->request->post();
|
||||
validate(GoodsValidate::class)->scene('re_audit')->check($params);
|
||||
} catch (ValidateException $e) {
|
||||
return JsonServer::error($e->getMessage());
|
||||
}
|
||||
$result = GoodsLogic::reAudit($params);
|
||||
if ($result) {
|
||||
return JsonServer::success('保存成功');
|
||||
}
|
||||
return JsonServer::error('保存失败');
|
||||
}
|
||||
|
||||
$goods_id = $this->request->get('goods_id', '', 'intval');
|
||||
return view('re_audit', [
|
||||
'goods_id' => $goods_id
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品设置
|
||||
*/
|
||||
public function setInfo()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
try {
|
||||
$params = $this->request->post();
|
||||
validate(GoodsValidate::class)->scene('set_info')->check($params);
|
||||
} catch (ValidateException $e) {
|
||||
return JsonServer::error($e->getMessage());
|
||||
}
|
||||
$result = GoodsLogic::setInfo($params);
|
||||
if ($result) {
|
||||
return JsonServer::success('设置成功');
|
||||
}
|
||||
return JsonServer::error('设置失败');
|
||||
}
|
||||
$goods_id = $this->request->get('goods_id', '', 'intval');
|
||||
$goods_detail = GoodsModel::find($goods_id);
|
||||
$goods_detail['column_ids'] = $goods_detail['column_ids'] ? explode(',', $goods_detail['column_ids']) : [];
|
||||
$goods_detail['column_ids'] = json_encode($goods_detail['column_ids']);
|
||||
$column_list = ColumnLogic::getList();
|
||||
return view('set_info', [
|
||||
'goods_id' => $goods_id,
|
||||
'column_list' => json_encode($column_list),
|
||||
'goods_detail' => $goods_detail
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核
|
||||
*/
|
||||
public function audit()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
try {
|
||||
$params = $this->request->post();
|
||||
validate(GoodsValidate::class)->scene('audit')->check($params);
|
||||
} catch (ValidateException $e) {
|
||||
return JsonServer::error($e->getMessage());
|
||||
}
|
||||
$result = GoodsLogic::audit($params);
|
||||
if ($result) {
|
||||
return JsonServer::success('操作完成');
|
||||
}
|
||||
return JsonServer::error('操作失败');
|
||||
}
|
||||
$goods_id = $this->request->get('goods_id', '', 'intval');
|
||||
return view('audit', [
|
||||
'goods_id' => $goods_id
|
||||
]);
|
||||
}
|
||||
|
||||
public function totalCount()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$get = $this->request->get();
|
||||
return JsonServer::success('获取成功', GoodsLogic::statistics($get));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 批量下架
|
||||
* @return \think\response\Json|\think\response\View
|
||||
* @author ljj
|
||||
* @date 2022/9/20 6:21 下午
|
||||
*/
|
||||
public function moreLower()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
try {
|
||||
$params = $this->request->post();
|
||||
validate(GoodsValidate::class)->scene('moreLower')->check($params);
|
||||
} catch (ValidateException $e) {
|
||||
return JsonServer::error($e->getMessage());
|
||||
}
|
||||
$result = GoodsLogic::moreLower($params);
|
||||
if (false === $result) {
|
||||
return JsonServer::error(GoodsLogic::getError());
|
||||
}
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
|
||||
$ids = $this->request->get('ids');
|
||||
return view('more_lower', [
|
||||
'ids' => $ids
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 批量审核
|
||||
* @return \think\response\Json|\think\response\View
|
||||
* @author ljj
|
||||
* @date 2022/9/20 6:38 下午
|
||||
*/
|
||||
public function moreAudit()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
try {
|
||||
$params = $this->request->post();
|
||||
validate(GoodsValidate::class)->scene('moreAudit')->check($params);
|
||||
} catch (ValidateException $e) {
|
||||
return JsonServer::error($e->getMessage());
|
||||
}
|
||||
$result = GoodsLogic::moreAudit($params);
|
||||
if (false === $result) {
|
||||
return JsonServer::error(GoodsLogic::getError());
|
||||
}
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
|
||||
$ids = $this->request->get('ids');
|
||||
return view('more_audit', [
|
||||
'ids' => $ids
|
||||
]);
|
||||
}
|
||||
}
|
||||
108
app/admin/controller/goods/Unit.php
Normal file
108
app/admin/controller/goods/Unit.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\admin\controller\goods;
|
||||
|
||||
|
||||
use app\admin\logic\goods\UnitLogic;
|
||||
use app\admin\validate\goods\UnitValidate;
|
||||
use app\common\basics\AdminBase;
|
||||
use app\common\model\goods\GoodsUnit as GoodsUnitModel;
|
||||
use app\common\server\JsonServer;
|
||||
|
||||
/**
|
||||
* 商品单位
|
||||
* Class GoodsUnit
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Unit extends AdminBase
|
||||
{
|
||||
/**
|
||||
* Notes: 列表
|
||||
* @author 段誉(2021/4/15 10:49)
|
||||
* @return string|\think\response\Json
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$get = $this->request->get();
|
||||
return JsonServer::success('获取成功', UnitLogic::lists($get));
|
||||
}
|
||||
return view();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 添加
|
||||
* @author 段誉(2021/4/15 10:49)
|
||||
* @return string|\think\response\Json
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$post = $this->request->post();
|
||||
(new UnitValidate())->goCheck('add');
|
||||
if (UnitLogic::addUnit($post)) {
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
return JsonServer::error(UnitLogic::getError() ?: '操作失败');
|
||||
}
|
||||
return view();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 编辑
|
||||
* @author 段誉(2021/4/15 10:49)
|
||||
* @return string|\think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$id = $this->request->get('unit_id');
|
||||
if ($this->request->isAjax()) {
|
||||
$post = $this->request->post();
|
||||
(new UnitValidate())->goCheck('edit');
|
||||
if (UnitLogic::editUnit($post)) {
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
return JsonServer::error(UnitLogic::getError() ?: '操作失败');
|
||||
}
|
||||
return view('', ['detail' => GoodsUnitModel::find($id)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 删除
|
||||
* @author 段誉(2021/4/15 10:49)
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$id = $this->request->post('id');
|
||||
(new UnitValidate())->goCheck('del');
|
||||
if (UnitLogic::del($id)) {
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
return JsonServer::error(UnitLogic::getError() ?: '操作失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user