Cards.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\cards\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 Cards 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', '=', 'cards' ] ], '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. if ($info[ 'data' ][ 'is_show_winner' ]) {
  30. $record = new Record();
  31. $record_data = $record->getGamesDrawRecordPageList([ [ 'game_id', '=', $game_id ], [ 'is_winning', '=', 1 ] ], 1, 10, 'create_time desc', 'member_nick_name,award_name,create_time');
  32. $info[ 'data' ][ 'draw_record' ] = $record_data[ 'data' ][ 'list' ];
  33. }
  34. // 剩余次数
  35. $token = $this->checkToken();
  36. $info[ 'data' ][ 'surplus_num' ] = 0;
  37. if ($info[ 'data' ][ 'join_frequency' ] && $token[ 'code' ] == 0) {
  38. $surplus_num = $game->getMemberSurplusNum($game_id, $this->member_id, $this->site_id);
  39. $info[ 'data' ][ 'surplus_num' ] = $surplus_num[ 'data' ];
  40. }
  41. }
  42. return $this->response($info);
  43. }
  44. /**
  45. * 抽奖
  46. * @return false|string
  47. */
  48. public function lottery()
  49. {
  50. $token = $this->checkToken();
  51. if ($token[ 'code' ] < 0) return $this->response($token);
  52. $game_id = $this->params[ 'id' ];
  53. $game = new Games();
  54. $res = $game->lottery($game_id, $this->member_id, $this->site_id);
  55. return $this->response($res);
  56. }
  57. }