|
|
@@ -16,11 +16,16 @@ namespace app\controller\admin\user;
|
|
|
|
|
|
use app\common\repositories\store\ExcelRepository;
|
|
|
use app\common\repositories\user\AwardIntegralPriceRepository;
|
|
|
+use app\common\repositories\user\OilLevelRepository;
|
|
|
use app\common\repositories\user\UserInfoRepository;
|
|
|
+use app\validate\admin\OilLevelValidate;
|
|
|
use crmeb\basic\BaseController;
|
|
|
use app\common\repositories\user\UserBillRepository;
|
|
|
use crmeb\services\ExcelService;
|
|
|
use think\App;
|
|
|
+use think\db\exception\DataNotFoundException;
|
|
|
+use think\db\exception\DbException;
|
|
|
+use think\db\exception\ModelNotFoundException;
|
|
|
|
|
|
/**
|
|
|
* Class Award
|
|
|
@@ -61,5 +66,101 @@ class Award extends BaseController
|
|
|
$where = $this->request->params(['type']);
|
|
|
return app('json')->success($this->repository->getLakeList($where, $page, $limit));
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 列表
|
|
|
+ * @return \think\response\Json
|
|
|
+ * @author Qinii
|
|
|
+ * @day 2023/9/24
|
|
|
+ */
|
|
|
+ public function oil_lst(OilLevelValidate $validate,OilLevelRepository $repository)
|
|
|
+ {
|
|
|
+ [$page, $limit] = $this->getPage();
|
|
|
+ $where = $this->request->params(['']);
|
|
|
+ return app('json')->success($this->repository->getList($where, $page, $limit));
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ * @param OilLevelValidate $validate
|
|
|
+ * @return mixed
|
|
|
+ * @author Qinii
|
|
|
+ */
|
|
|
+ public function create(OilLevelValidate $validate,OilLevelRepository $repository)
|
|
|
+ {
|
|
|
+ $data = $this->checkParams($validate);
|
|
|
+ $grade = $repository->where('grade', $data['grade'])->find();
|
|
|
+ if ($grade){
|
|
|
+ return app('json')->fail('等级已存在');
|
|
|
+ }
|
|
|
+ $repository->create($data);
|
|
|
+ return app('json')->success('添加成功');
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 文章详情
|
|
|
+ * @param $id
|
|
|
+ * @return \think\response\Json
|
|
|
+ * @author wuhaotian
|
|
|
+ * @email 442384644@qq.com
|
|
|
+ * @date 2024/7/4
|
|
|
+ */
|
|
|
+ public function detail($id,OilLevelRepository $repository)
|
|
|
+ {
|
|
|
+// if (!$this->repository->merExists($this->request->merId(), $id))
|
|
|
+// return app('json')->fail('数据不存在');
|
|
|
|
|
|
+ return app('json')->success($repository->getWith($id));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新
|
|
|
+ * @param $id
|
|
|
+ * @param OilLevelValidate $validate
|
|
|
+ * @return mixed
|
|
|
+ * @author Qinii
|
|
|
+ */
|
|
|
+ public function update($id, OilLevelValidate $validate,OilLevelRepository $repository)
|
|
|
+ {
|
|
|
+ $data = $this->checkParams($validate);
|
|
|
+// if (!$this->repository->merExists($this->request->merId(), $id))
|
|
|
+// return app('json')->fail('数据不存在');
|
|
|
+ $grade = $repository->where('grade', $data['grade'])->find();
|
|
|
+ if ($grade){
|
|
|
+ return app('json')->fail('等级已存在');
|
|
|
+ }
|
|
|
+ $repository->update($id, $data);
|
|
|
+
|
|
|
+ return app('json')->success('编辑成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ * @param $id
|
|
|
+ * @return mixed
|
|
|
+ * @throws DataNotFoundException
|
|
|
+ * @throws DbException
|
|
|
+ * @throws ModelNotFoundException
|
|
|
+ * @author Qinii
|
|
|
+ */
|
|
|
+ public function delete($id,OilLevelRepository $repository)
|
|
|
+ {
|
|
|
+// if (!$this->repository->merExists($this->request->merId(), $id))
|
|
|
+// return app('json')->fail('数据不存在');
|
|
|
+
|
|
|
+ $repository->delete($id);
|
|
|
+
|
|
|
+ return app('json')->success('删除成功');
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 验证数据
|
|
|
+ * @param OilLevelValidate $validate
|
|
|
+ * @return array
|
|
|
+ * @author Qinii
|
|
|
+ */
|
|
|
+ public function checkParams(OilLevelValidate $validate)
|
|
|
+ {
|
|
|
+ $data = $this->request->params(['name', 'grade', 'achievement','award_ratio']);
|
|
|
+ $validate->check($data);
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
}
|