GiftController.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /**
  3. * GiftController.php UTF-8
  4. *
  5. *
  6. * @date : 2018/6/11 15:43
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : luowei <lw@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace api\wapapp\controller\v8;
  13. use api\common\controller\V2ApiBaseController;
  14. use huo\controller\gift\Gift;
  15. use huolib\status\CommonStatus;
  16. class GiftController extends V2ApiBaseController {
  17. public function __construct() {
  18. parent::__construct();
  19. }
  20. /**
  21. * 礼包列表
  22. * http://doc.1tsdk.com/138?page_id=2845
  23. * 【域名】/gift/list
  24. */
  25. public function index() {
  26. $_mem_id = $this->mem_id;
  27. $_page = $this->request->param('page/d', 1);
  28. $_offset = $this->request->param('offset/d', 10);
  29. $_app_id = $this->request->param('game_id/d', 0);
  30. $_type = $this->request->param('type/d', 0);/* 礼包类型 1 普通(不需要积分和加群) 2 需要积分 3 需要加群 */
  31. $_map = [];
  32. !empty($_app_id) && $_map['app_id'] = $_app_id;
  33. !empty($_type) && $_map['gift_type'] = $_type;
  34. $_gift_class = new Gift();
  35. $_rs = $_gift_class->getGifts($_mem_id, $_map, $_page.','.$_offset);
  36. if (CommonStatus::NO_ERROR != $_rs['code']) {
  37. $this->error($_rs['msg'], $_rs['data'], $_rs['code']);
  38. }
  39. $this->success(lang('SUCCESS'), $_rs['data'], $_rs['code']);
  40. }
  41. /**
  42. * 玩家礼包列表
  43. * http://doc.1tsdk.com/138?page_id=2846
  44. * 【域名】/v8/user/gift/list
  45. */
  46. public function myIndex() {
  47. $_mem_id = $this->getMemId();
  48. $_param = $this->request->param();
  49. $result = $this->validate($_param, 'Gift.list');
  50. if ($result !== true) {
  51. $this->error($result);
  52. }
  53. $_page = $this->request->param('page/d', 1);
  54. $_offset = $this->request->param('offset/d', 10);
  55. $_gift_class = new Gift();
  56. $_rs = $_gift_class->getMemGifts($_mem_id, $_page.','.$_offset);
  57. if (CommonStatus::NO_ERROR != $_rs['code']) {
  58. $this->error($_rs['msg'], $_rs['data'], $_rs['code']);
  59. }
  60. $this->success(lang('SUCCESS'), $_rs['data'], $_rs['code']);
  61. }
  62. /**
  63. * 领取礼包
  64. * http://doc.1tsdk.com/138?page_id=2847
  65. * 【域名】/user/gift/add
  66. */
  67. public function save() {
  68. $_mem_id = $this->getMemId();
  69. $_param = $this->request->param();
  70. $result = $this->validate($_param, 'Gift.detail');
  71. if ($result !== true) {
  72. $this->error($result);
  73. }
  74. $_gift_class = new Gift();
  75. $_rs = $_gift_class->setGift($_mem_id, $_param['gift_id']);
  76. if (CommonStatus::NO_ERROR != $_rs['code']) {
  77. $this->error($_rs['msg'], $_rs['data'], $_rs['code']);
  78. }
  79. $this->success(lang('SUCCESS'), $_rs['data'], $_rs['code']);
  80. }
  81. /**
  82. * 礼包详情
  83. * http://doc.1tsdk.com/138?page_id=2848
  84. * 【域名】/gift/detail
  85. */
  86. public function read() {
  87. $_mem_id = $this->mem_id;
  88. $_param = $this->request->param();
  89. $result = $this->validate($_param, 'Gift.detail');
  90. if ($result !== true) {
  91. $this->error($result);
  92. }
  93. $_gift_class = new Gift();
  94. $_gift_class->getGiftDetail($_param['gift_id'], $_mem_id);
  95. $_rs = $_gift_class->getGiftDetail($_param['gift_id'], $_mem_id);
  96. if (CommonStatus::NO_ERROR != $_rs['code']) {
  97. $this->error($_rs['msg'], $_rs['data'], $_rs['code']);
  98. }
  99. $this->success(lang('SUCCESS'), $_rs['data'], $_rs['code']);
  100. }
  101. /**
  102. * 游戏礼包
  103. * http://doc.1tsdk.com/138?page_id=3107
  104. * 【域名】/game/gift/list
  105. */
  106. public function gameList() {
  107. return $this->index();
  108. }
  109. /**
  110. * 玩家礼包列表
  111. * http://doc.1tsdk.com/138?page_id=2846
  112. * 【域名】/user/gift/list
  113. */
  114. public function memList() {
  115. $_mem_id = $this->getMemId();
  116. $_page = $this->request->param('page/d', 1);
  117. $_offset = $this->request->param('offset/d', 10);
  118. $_gift_class = new Gift();
  119. $_rs = $_gift_class->getMemGifts($_mem_id, $_page.','.$_offset);
  120. if (CommonStatus::NO_ERROR != $_rs['code']) {
  121. $this->error($_rs['msg'], $_rs['data'], $_rs['code']);
  122. }
  123. $this->success(lang('SUCCESS'), $_rs['data'], $_rs['code']);
  124. }
  125. }