| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- <?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\model\user\AwardLake;
- use app\common\repositories\store\ExcelRepository;
- use app\common\repositories\user\AwardIntegralPriceRepository;
- use app\common\repositories\user\GiftLevelRepository;
- use app\common\repositories\user\OilLevelRepository;
- use app\common\repositories\user\UserInfoRepository;
- use app\validate\admin\GiftLevelValidate;
- 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 Award 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));
- }
- /**
- * 奖池列表
- * @return \think\response\Json
- * @author Qinii
- * @day 2023/9/24
- */
- public function lake_lst()
- {
- [$page, $limit] = $this->getPage();
- $where = $this->request->params(['type']);
- $list=$this->repository->getLakeList($where, $page, $limit);
- foreach ($list['list'] as $k=>&$v){
- $list['list'][$k]['send_time'] = date('Y-m-d H:i:s',$list['list'][$k]['send_time']);
- if (strpos($v['award_name'],'服务中心')!==false){
- unset($list['list'][$k]);
- }
- }
- return app('json')->success($list);
- }
- /**
- * 奖池变动记录列表
- * @return \think\response\Json
- * @author Qinii
- * @day 2023/9/24
- */
- public function lake_log_lst()
- {
- [$page, $limit] = $this->getPage();
- $where = $this->request->params(['type','pm']);
- $list=$this->repository->getLakeLogList($where, $page, $limit);
- foreach ($list['list'] as $k=>&$v){
- $list['list'][$k]['add_time'] = date('Y-m-d H:i:s',$list['list'][$k]['add_time']);
- }
- return app('json')->success($list);
- }
- /**
- * 列表
- * @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($repository->getList($where, $page, $limit));
- }
- /**
- * 添加
- * @param OilLevelValidate $validate
- * @return mixed
- * @author Qinii
- */
- public function oil_create(OilLevelValidate $validate,OilLevelRepository $repository)
- {
- $data = $this->oil_checkParams($validate);
- $grade = app()->make(OilLevelRepository::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 oil_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
- */
- public function oil_update($id, OilLevelValidate $validate,OilLevelRepository $repository)
- {
- $data = $this->oil_checkParams($validate);
- // if (!$this->repository->merExists($this->request->merId(), $id))
- // return app('json')->fail('数据不存在');
- $grade = app()->make(OilLevelRepository::class)->getSearch([])->whereNotIn('id',[$id])->where('grade', $data['grade'])->find();
- if ($grade){
- return app('json')->fail('等级已存在');
- }
- $data['update_time']=time();
- $repository->update($id, $data);
- return app('json')->success('编辑成功');
- }
- /**
- * 删除
- */
- public function oil_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 oil_checkParams(OilLevelValidate $validate)
- {
- $data = $this->request->params(['name', 'grade', 'achievement','award_ratio']);
- $validate->check($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('等级已存在');
- }
- $data['update_time']=time();
- $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;
- }
- // 手动分红
- public function hand_send(AwardLake $awardLake){
- $lst = $awardLake->handSend();
- return app('json')->success($lst);
- }
- }
|