Lottery.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\shop\controller\plus;
  3. use app\shop\controller\Controller;
  4. use app\shop\model\plus\lottery\Lottery as LotteryModel;
  5. use app\shop\model\plus\lottery\Record as RecordModel;
  6. use app\shop\model\plus\lottery\LotteryPrize as LotteryPrizeModel;
  7. /**
  8. * 转盘控制器
  9. */
  10. class Lottery extends Controller
  11. {
  12. /**
  13. * 获取数据
  14. * @param null $id
  15. */
  16. public function getLottery()
  17. {
  18. $model = new LotteryModel();
  19. $data = $model->getLottery();
  20. $data['prize'] = $data ? LotteryPrizeModel::detail($data['lottery_id']) : [];
  21. return $this->renderSuccess('', compact('data'));
  22. }
  23. /**
  24. *修改
  25. */
  26. public function setting()
  27. {
  28. $model = new LotteryModel();
  29. if ($model->edit($this->postData())) {
  30. return $this->renderSuccess('修改成功');
  31. }
  32. return $this->renderError($model->getError() ?: '修改失败');
  33. }
  34. /*
  35. * 转盘记录列表
  36. */
  37. public function record()
  38. {
  39. $model = new RecordModel();
  40. $list = $model->getList($this->postData());
  41. return $this->renderSuccess('', compact('list'));
  42. }
  43. /**
  44. * 获取下架奖项
  45. * @param null $id
  46. */
  47. public function award()
  48. {
  49. $model = new LotteryModel();
  50. $data = $model->getLottery();
  51. $list = LotteryPrizeModel::getlist($this->postData(), $data['lottery_id']);
  52. return $this->renderSuccess('', compact('list'));
  53. }
  54. }