GiftController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * GiftController.php UTF-8
  4. *
  5. *
  6. * @date : 2018/5/28 16:48
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : luowei <lw@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace api\cfloat\controller;
  13. use api\common\controller\CFloatBaseController;
  14. use huo\controller\gift\Gift;
  15. use huolib\status\CommonStatus;
  16. use think\Lang;
  17. class GiftController extends CFloatBaseController {
  18. public function _initialize() {
  19. parent::_initialize();
  20. $langSet = $this->request->langset();
  21. Lang::load([APP_PATH.'cfloat'.DS.'lang'.DS.$langSet.DS.'gift'.EXT,]);
  22. $this->checkLogin();
  23. }
  24. /**
  25. * Client浮点获取礼包列表
  26. * http://doc.1tsdk.com/138?page_id=3276
  27. * 【域名】/cfloat/gift/list
  28. */
  29. public function index() {
  30. $_mem_id = $this->mem_id;
  31. $_param = $this->request->param();
  32. $result = $this->validate($_param, 'Gift.list');
  33. if ($result !== true) {
  34. $this->error($result);
  35. }
  36. $_app_id = $this->request->param('game_id/d', 0);
  37. $_page = $this->request->param('page/d', 1);
  38. $_offset = $this->request->param('offset/d', 10);
  39. $_is_get = $this->request->param('is_get/d', 0); //是否已经领取过的,2表示领取过的,不传表示请求全部
  40. $_is_received = $this->request->param('is_received/d', 0); //2 只获取已领取的礼包 其他表示请求全部
  41. $_gift_class = new Gift();
  42. $_map = [];
  43. if (!empty($_app_id)) {
  44. $_map['app_id'] = $_app_id;
  45. }
  46. $_inc_me = $_received = false;
  47. if (2 == $_is_get) {
  48. $_inc_me = true;
  49. }
  50. if (2 == $_is_received) {
  51. $_received = true;
  52. }
  53. if ($_received) {
  54. $_rs = $_gift_class->getMemGifts($_mem_id, $_page.','.$_offset);
  55. } else {
  56. $_rs = $_gift_class->getGifts($_mem_id, $_map, $_page.','.$_offset, $_inc_me);
  57. }
  58. if (CommonStatus::NO_ERROR != $_rs['code']) {
  59. $this->error($_rs['msg'], $_rs['data'], $_rs['code']);
  60. }
  61. $this->success(lang('SUCCESS'), $_rs['data'], $_rs['code']);
  62. }
  63. /**
  64. * Client浮点获取礼包详情页
  65. * http://doc.1tsdk.com/138?page_id=3277
  66. * 【域名】/cfloat/gift/detail
  67. */
  68. public function detail() {
  69. $_mem_id = $this->mem_id;
  70. $_param = $this->request->param();
  71. $result = $this->validate($_param, 'Gift.detail');
  72. if ($result !== true) {
  73. $this->error($result);
  74. }
  75. $_gift_class = new Gift();
  76. $_rs = $_gift_class->getGiftDetail($_param['gift_id'], $_mem_id);
  77. if (CommonStatus::NO_ERROR != $_rs['code']) {
  78. $this->error($_rs['msg'], $_rs['data'], $_rs['code']);
  79. }
  80. $this->success(lang('SUCCESS'), $_rs['data'], $_rs['code']);
  81. }
  82. /**
  83. * Client浮点获取礼包领取
  84. * http://doc.1tsdk.com/138?page_id=3278
  85. * 【域名】/cfloat/user/gift/add
  86. */
  87. public function add() {
  88. $_mem_id = $this->mem_id;
  89. $_param = $this->request->param();
  90. $result = $this->validate($_param, 'Gift.detail');
  91. if ($result !== true) {
  92. $this->error($result);
  93. }
  94. $_gift_class = new Gift();
  95. $_rs = $_gift_class->setGift($_mem_id, $_param['gift_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. }