2024-11-12 15:37:05 +08:00
|
|
|
<?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();
|
|
|
|
|
return JsonServer::success('获取成功', SubsidyLogic::lists($get));
|
|
|
|
|
}
|
2024-11-13 12:00:42 +08:00
|
|
|
|
|
|
|
|
return view('', [
|
|
|
|
|
'config' => SubsidyLogic::getSubsidyConfig()
|
|
|
|
|
]);
|
2024-11-12 15:37:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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() ?: '操作失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-13 12:00:42 +08:00
|
|
|
|
|
|
|
|
// 设置全局返补比例
|
|
|
|
|
public function setSubsidyConfig()
|
|
|
|
|
{
|
|
|
|
|
if ($this->request->isAjax()) {
|
|
|
|
|
$post = $this->request->post();
|
|
|
|
|
if (SubsidyLogic::setSubsidyConfig($post)) {
|
|
|
|
|
return JsonServer::success('操作成功');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return JsonServer::error(SubsidyLogic::getError() ?: '操作失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-12 15:37:05 +08:00
|
|
|
}
|