79 lines
2.2 KiB
PHP
79 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller\goods;
|
|
|
|
use app\common\basics\AdminBase;
|
|
use app\admin\validate\goods\SubsidyValidate;
|
|
use app\admin\logic\goods\SubsidyLogic;
|
|
use app\common\model\goods\GoodsSubsidy;
|
|
use app\common\server\JsonServer;
|
|
|
|
class Subsidy extends AdminBase
|
|
{
|
|
public function lists()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$get = $this->request->get();
|
|
$lists = (new GoodsSubsidy())->getSubsidy($get);
|
|
return JsonServer::success('获取成功', $lists);
|
|
}
|
|
|
|
return view('', [
|
|
'config' => SubsidyLogic::getSubsidyConfig()
|
|
]);
|
|
}
|
|
|
|
public function add()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$post = $this->request->post();
|
|
(new SubsidyValidate())->goCheck();
|
|
if (SubsidyLogic::add($post)) {
|
|
return JsonServer::success('操作成功');
|
|
}
|
|
return JsonServer::error(SubsidyLogic::getError() ?: '操作失败');
|
|
}
|
|
return view();
|
|
}
|
|
|
|
public function edit()
|
|
{
|
|
$id = $this->request->get('id');
|
|
if ($this->request->isAjax()) {
|
|
$post = $this->request->post();
|
|
(new SubsidyValidate())->goCheck();
|
|
if (SubsidyLogic::edit($post)) {
|
|
return JsonServer::success('操作成功');
|
|
}
|
|
return JsonServer::error(SubsidyLogic::getError() ?: '操作失败');
|
|
}
|
|
|
|
return view('', [
|
|
'detail' => GoodsSubsidy::find($id),
|
|
]);
|
|
}
|
|
|
|
public function del()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$id = $this->request->post('id');
|
|
if (SubsidyLogic::del($id)) {
|
|
return JsonServer::success('操作成功');
|
|
}
|
|
return JsonServer::error(SubsidyLogic::getError() ?: '操作失败');
|
|
}
|
|
}
|
|
|
|
// 设置全局返补比例
|
|
public function setSubsidyConfig()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$post = $this->request->post();
|
|
if (SubsidyLogic::setSubsidyConfig($post)) {
|
|
return JsonServer::success('操作成功');
|
|
}
|
|
|
|
return JsonServer::error(SubsidyLogic::getError() ?: '操作失败');
|
|
}
|
|
}
|
|
} |