|
@@ -16,8 +16,10 @@ namespace app\controller\admin\user;
|
|
|
|
|
|
|
|
use app\common\repositories\store\ExcelRepository;
|
|
use app\common\repositories\store\ExcelRepository;
|
|
|
use app\common\repositories\user\AwardIntegralPriceRepository;
|
|
use app\common\repositories\user\AwardIntegralPriceRepository;
|
|
|
|
|
+use app\common\repositories\user\GiftLevelRepository;
|
|
|
use app\common\repositories\user\OilLevelRepository;
|
|
use app\common\repositories\user\OilLevelRepository;
|
|
|
use app\common\repositories\user\UserInfoRepository;
|
|
use app\common\repositories\user\UserInfoRepository;
|
|
|
|
|
+use app\validate\admin\GiftLevelValidate;
|
|
|
use app\validate\admin\OilLevelValidate;
|
|
use app\validate\admin\OilLevelValidate;
|
|
|
use crmeb\basic\BaseController;
|
|
use crmeb\basic\BaseController;
|
|
|
use app\common\repositories\user\UserBillRepository;
|
|
use app\common\repositories\user\UserBillRepository;
|
|
@@ -151,4 +153,78 @@ class Award extends BaseController
|
|
|
$validate->check($data);
|
|
$validate->check($data);
|
|
|
return $data;
|
|
return $data;
|
|
|
}
|
|
}
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 列表
|
|
|
|
|
+ * @return \think\response\Json
|
|
|
|
|
+ * @author Qinii
|
|
|
|
|
+ * @day 2023/9/24
|
|
|
|
|
+ */
|
|
|
|
|
+ public function gift_lst(GiftLevelValidate $validate,GiftLevelRepository $repository)
|
|
|
|
|
+ {
|
|
|
|
|
+ [$page, $limit] = $this->getPage();
|
|
|
|
|
+ $where = $this->request->params(['']);
|
|
|
|
|
+ return app('json')->success($repository->getList($where, $page, $limit));
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 添加
|
|
|
|
|
+ * @param GiftLevelValidate $validate
|
|
|
|
|
+ * @return mixed
|
|
|
|
|
+ * @author Qinii
|
|
|
|
|
+ */
|
|
|
|
|
+ public function gift_create(GiftLevelValidate $validate,GiftLevelRepository $repository)
|
|
|
|
|
+ {
|
|
|
|
|
+ $data = $this->gift_checkParams($validate);
|
|
|
|
|
+ $grade = app()->make(GiftLevelRepository::class)->getSearch([])->where('grade', $data['grade'])->find();
|
|
|
|
|
+ if ($grade){
|
|
|
|
|
+ return app('json')->fail('等级已存在');
|
|
|
|
|
+ }
|
|
|
|
|
+ $data['update_time'] = time();
|
|
|
|
|
+ $repository->create($data);
|
|
|
|
|
+ return app('json')->success('添加成功');
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更新
|
|
|
|
|
+ * @param $id
|
|
|
|
|
+ */
|
|
|
|
|
+ public function gift_update($id, GiftLevelValidate $validate,GiftLevelRepository $repository)
|
|
|
|
|
+ {
|
|
|
|
|
+ $data = $this->gift_checkParams($validate);
|
|
|
|
|
+// if (!$this->repository->merExists($this->request->merId(), $id))
|
|
|
|
|
+// return app('json')->fail('数据不存在');
|
|
|
|
|
+ $grade = app()->make(GiftLevelRepository::class)->getSearch([])->whereNotIn('id',[$id])->where('grade', $data['grade'])->find();
|
|
|
|
|
+ if ($grade){
|
|
|
|
|
+ return app('json')->fail('等级已存在');
|
|
|
|
|
+ }
|
|
|
|
|
+ $repository->update($id, $data);
|
|
|
|
|
+
|
|
|
|
|
+ return app('json')->success('编辑成功');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除
|
|
|
|
|
+ */
|
|
|
|
|
+ public function gift_delete($id,GiftLevelRepository $repository)
|
|
|
|
|
+ {
|
|
|
|
|
+// if (!$this->repository->merExists($this->request->merId(), $id))
|
|
|
|
|
+// return app('json')->fail('数据不存在');
|
|
|
|
|
+
|
|
|
|
|
+ $repository->delete($id);
|
|
|
|
|
+
|
|
|
|
|
+ return app('json')->success('删除成功');
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 验证数据
|
|
|
|
|
+ * @param GiftLevelValidate $validate
|
|
|
|
|
+ * @return array
|
|
|
|
|
+ * @author Qinii
|
|
|
|
|
+ */
|
|
|
|
|
+ public function gift_checkParams(GiftLevelValidate $validate)
|
|
|
|
|
+ {
|
|
|
|
|
+ $data = $this->request->params(['name', 'grade', 'achievement','award_ratio']);
|
|
|
|
|
+ $validate->check($data);
|
|
|
|
|
+ return $data;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|