GiftController.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /**
  3. * GiftController.php UTF-8
  4. * H5 WAP 礼包
  5. *
  6. * @date : 2018/4/27 21:11
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : liuhongliang <lhl@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace h5wap\wap\controller;
  13. use h5wap\common\controller\V2BaseController;
  14. use huo\controller\gift\Gift;
  15. use huo\controller\member\Member;
  16. use huo\controller\sign\Sign;
  17. use huo\controller\wap\Option;
  18. use huolib\constant\GameConst;
  19. use huolib\status\GiftStatus;
  20. class GiftController extends V2BaseController {
  21. protected $from;
  22. public function _initialize() {
  23. parent::_initialize();
  24. $this->from = GameConst::GAME_H5;
  25. }
  26. /**
  27. * h5wap礼包首页
  28. * http://doc.1tsdk.com/138?page_id=3110
  29. *
  30. * 【域名】/wap/gift/index
  31. *
  32. * @return mixed
  33. * @throws \think\Exception
  34. */
  35. public function index() {
  36. $_user_info = (new Member())->getMemInfo($this->mem_id);
  37. $this->assign('userinfo', $_user_info);
  38. $_from = $this->from;
  39. $_page = '1,10';
  40. $_game_gifts = (new Gift())->getGameGifts($this->mem_id, $_from, $_page);
  41. $this->assign('gamegift', $_game_gifts['data']);
  42. $_sign_conf = (new Sign())->getSignConf();
  43. $_sign_list['count'] = count($_sign_conf);
  44. $_sign_list['list'] = $_sign_conf;
  45. $this->assign('sign_list', $_sign_list);
  46. //添加seo优化信息
  47. $_seo_data = Option::ins()->getSeoValue('h5_wap_giftindex_seo');
  48. $this->assign('seo', $_seo_data);
  49. return $this->fetch('gift/index');
  50. }
  51. /**
  52. * 礼包详情页
  53. * http://doc.1tsdk.com/138?page_id=3110
  54. * 【域名】/wap/gift/detail
  55. *
  56. * @return mixed
  57. * @throws \think\Exception
  58. */
  59. public function read() {
  60. $_mem_id = $this->mem_id;
  61. $_gift_id = $this->request->param('gift_id/d', 0);
  62. $_gift_class = new Gift();
  63. $_rdata = $_gift_class->getGiftDetail($_gift_id, $_mem_id);
  64. if (GiftStatus::NO_ERROR != $_rdata['code']) {
  65. $this->returnData($_rdata);
  66. }
  67. $this->assign('gift', $_rdata['data']);
  68. //添加seo优化信息
  69. $_seo_data = Option::ins()->getSeoValue('h5_wap_giftdetails_seo', 0, $_gift_id);
  70. $this->assign('seo', $_seo_data);
  71. return $this->fetch('gift/detail');
  72. }
  73. /**
  74. * 游戏礼包列表
  75. * http://doc.1tsdk.com/138?page_id=3234
  76. * 【域名】/wap/game/gift/list
  77. *
  78. * @throws \think\db\exception\DataNotFoundException
  79. * @throws \think\db\exception\ModelNotFoundException
  80. * @throws \think\exception\DbException
  81. */
  82. public function game() {
  83. $_mem_id = $this->mem_id;
  84. $_from = $this->from;
  85. $_page = $this->request->param('page/d', 1);
  86. $_offset = $this->request->param('offset/d', 10);
  87. $_page = $_page.','.$_offset;
  88. $_game_gifts = (new Gift())->getGameGifts($_mem_id, $_from, $_page);
  89. if (GiftStatus::NO_ERROR != $_game_gifts['code']) {
  90. $this->returnData($_game_gifts);
  91. }
  92. $this->returnData($_game_gifts);
  93. }
  94. /**
  95. * 礼包领取
  96. * http://doc.1tsdk.com/138?page_id=3218
  97. * 【域名】/wap/user/gift/add
  98. *
  99. */
  100. public function save() {
  101. $this->checkLogin();
  102. $_mem_id = $this->mem_id;
  103. $_gift_id = $this->request->param('gift_id/d', 0);
  104. $_gift_class = new Gift();
  105. $_rs = $_gift_class->setGift($_mem_id, $_gift_id);
  106. if (GiftStatus::NO_ERROR != $_rs['code']) {
  107. $this->returnData($_rs);
  108. }
  109. $this->returnData($_rs);
  110. }
  111. }