LuckdrawRecord.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace app\data\controller;
  3. use think\admin\Controller;
  4. /**
  5. * 奖品领取记录
  6. * Class LuckdrawRecord
  7. * @package app\activity\controller
  8. */
  9. class LuckdrawRecord extends Controller
  10. {
  11. /**
  12. * 绑定数据表
  13. * @var string
  14. */
  15. protected $table = 'ActivityLuckdrawRecord';
  16. /**
  17. * 中奖记录管理
  18. * @auth true
  19. * @menu true
  20. * @throws \think\Exception
  21. * @throws \think\db\exception\DataNotFoundException
  22. * @throws \think\db\exception\ModelNotFoundException
  23. * @throws \think\exception\DbException
  24. * @throws \think\exception\PDOException
  25. */
  26. public function index()
  27. {
  28. $this->title = '中奖记录管理';
  29. $query = $this->_query($this->table)->like('phone,username,prize_name,prize_level');
  30. $query->equal('uncode_status,code')->dateBetween('create_at,uncode_datetime')->order('id desc');
  31. if (input('output') === 'json') {
  32. $result = $query->page(true, false);
  33. $this->success('获取数据列表成功', $result);
  34. } else {
  35. $query->page();
  36. }
  37. }
  38. /**
  39. * 页面数据处理
  40. * @param array $data
  41. * @throws \think\db\exception\DataNotFoundException
  42. * @throws \think\db\exception\DbException
  43. * @throws \think\db\exception\ModelNotFoundException
  44. */
  45. protected function _page_filter(array &$data)
  46. {
  47. $this->prizes = $this->app->db->name('ActivityLuckdrawConfig')->where(['deleted' => 0])->order('id desc')->select()->toArray();
  48. $members = $this->app->db->name('ActivityLuckdrawMember')->whereIn('id', array_unique(array_column($data, 'mid')))->column('*', 'mid');
  49. $acitves = $this->app->db->name('ActivityLuckdrawConfig')->whereIn('code', array_unique(array_column($data, 'code')))->column('*', 'code');
  50. foreach ($data as &$vo) {
  51. $vo['info'] = $acitves[$vo['code']] ?? [];
  52. $vo['member'] = $members[$vo['mid']] ?? [];
  53. }
  54. }
  55. }