Egg.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\egg\api\controller;
  11. use app\api\controller\BaseApi;
  12. use app\model\games\Games;
  13. use app\model\games\Record;
  14. /**
  15. * 大转盘
  16. */
  17. class Egg extends BaseApi
  18. {
  19. /**
  20. * 基础信息
  21. */
  22. public function info()
  23. {
  24. $game_id = $this->params[ 'id' ] ?? 0;
  25. $game = new Games();
  26. $info = $game->getGamesInfo([ [ 'game_id', '=', $game_id ], [ 'site_id', '=', $this->site_id ], [ 'game_type', '=', 'egg' ] ], 'game_id,game_name,points,start_time,end_time,status,remark,no_winning_desc,no_winning_img,is_show_winner,level_id,level_name,join_type,join_frequency');
  27. if (!empty($info[ 'data' ])) {
  28. // 奖项
  29. $game_ward = $game->getGameAward([ [ 'game_id', '=', $game_id ] ], 'award_id,award_name,award_img');
  30. $game_ward = $game_ward[ 'data' ];
  31. $info[ 'data' ][ 'award' ] = $game_ward;
  32. // 中奖名单
  33. if ($info[ 'data' ][ 'is_show_winner' ]) {
  34. $record = new Record();
  35. $record_data = $record->getGamesDrawRecordPageList([ [ 'game_id', '=', $game_id ], [ 'is_winning', '=', 1 ] ], 1, 10, 'create_time desc', 'member_nick_name,award_name,create_time');
  36. $info[ 'data' ][ 'draw_record' ] = $record_data[ 'data' ][ 'list' ];
  37. }
  38. // 剩余次数
  39. $token = $this->checkToken();
  40. $info[ 'data' ][ 'surplus_num' ] = 0;
  41. if ($info[ 'data' ][ 'join_frequency' ] && $token[ 'code' ] == 0) {
  42. $surplus_num = $game->getMemberSurplusNum($game_id, $this->member_id, $this->site_id);
  43. $info[ 'data' ][ 'surplus_num' ] = $surplus_num[ 'data' ];
  44. }
  45. }
  46. return $this->response($info);
  47. }
  48. /**
  49. * 抽奖
  50. * @return false|string
  51. */
  52. public function lottery()
  53. {
  54. $token = $this->checkToken();
  55. if ($token[ 'code' ] < 0) return $this->response($token);
  56. $game_id = $this->params[ 'id' ];
  57. $game = new Games();
  58. $res = $game->lottery($game_id, $this->member_id, $this->site_id);
  59. return $this->response($res);
  60. }
  61. }