|
|
@@ -0,0 +1,144 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | Author: CRMEB Team <admin@crmeb.com>
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+
|
|
|
+
|
|
|
+namespace app\controller\admin\user;
|
|
|
+
|
|
|
+
|
|
|
+use app\common\dao\user\OilLevelDao;
|
|
|
+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
|
|
|
+ * app\controller\admin\user
|
|
|
+ * 用户扩展字段设置
|
|
|
+ */
|
|
|
+class OilLevel extends BaseController
|
|
|
+{
|
|
|
+ protected $repository;
|
|
|
+
|
|
|
+ public function __construct(App $app, AwardIntegralPriceRepository $repository)
|
|
|
+ {
|
|
|
+ parent::__construct($app);
|
|
|
+ $this->repository = $repository;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 列表
|
|
|
+ * @return \think\response\Json
|
|
|
+ * @author Qinii
|
|
|
+ * @day 2023/9/24
|
|
|
+ */
|
|
|
+ public function lst()
|
|
|
+ {
|
|
|
+ [$page, $limit] = $this->getPage();
|
|
|
+ $where = $this->request->params(['day']);
|
|
|
+ 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('等级已存在');
|
|
|
+ }
|
|
|
+ $this->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)
|
|
|
+ {
|
|
|
+// if (!$this->repository->merExists($this->request->merId(), $id))
|
|
|
+// return app('json')->fail('数据不存在');
|
|
|
+
|
|
|
+ return app('json')->success($this->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('等级已存在');
|
|
|
+ }
|
|
|
+ $this->repository->update($id, $data);
|
|
|
+
|
|
|
+ return app('json')->success('编辑成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ * @param $id
|
|
|
+ * @return mixed
|
|
|
+ * @throws DataNotFoundException
|
|
|
+ * @throws DbException
|
|
|
+ * @throws ModelNotFoundException
|
|
|
+ * @author Qinii
|
|
|
+ */
|
|
|
+ public function delete($id)
|
|
|
+ {
|
|
|
+// if (!$this->repository->merExists($this->request->merId(), $id))
|
|
|
+// return app('json')->fail('数据不存在');
|
|
|
+
|
|
|
+ $this->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;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|