GiftController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * GiftController.php UTF-8
  4. * 礼包处理类
  5. *
  6. * @date : 2018/1/19 16:25
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : linjiebin <ljb@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace web\pc\controller\v8;
  13. use think\Session;
  14. use web\common\controller\WebBaseController;
  15. use web\pc\logic\GiftLogic;
  16. class GiftController extends WebBaseController {
  17. public function __construct() {
  18. parent::__construct();
  19. }
  20. public function index() {
  21. $_web_info = $this->web_info;
  22. $this->set_seo($_web_info['web_basic']['company_name']);
  23. $_gift_class = new GiftLogic();
  24. $_name = $this->request->param('giftname', '');
  25. $_page = $this->request->param('page', 1);
  26. $_row = $this->request->param('row', 8);
  27. $_map = [];
  28. if (!empty($_name)) {
  29. $_map['gf.title|g.name'] = ['like', "%$_name%"];
  30. }
  31. $_rdata['gift'] = $_gift_class->getGifts(0, $_map, $_page.','.$_row);
  32. if($this->request->isAjax()){
  33. return $_rdata;
  34. }
  35. // print_r($_rdata);
  36. $this->assign($_rdata);
  37. return $this->fetch('Gift/index');
  38. }
  39. public function set_gift() {
  40. if ($this->request->isAjax()) {
  41. if (!$this->isLogin()) {
  42. return ['error' => 1, 'msg' => '未登录'];
  43. }
  44. $_giftid = $this->request->param('giftid');
  45. $_gift_class = new GiftLogic();
  46. $_mem_id = Session::get('user.id');
  47. $_res = $_gift_class->setGift($_mem_id, $_giftid);
  48. if (601 == $_res) {
  49. return ['error' => 2, 'msg' => '礼包已下架'];
  50. }
  51. if (602 == $_res) {
  52. return ['error' => 3, 'msg' => '已经领取过了,请到个人中心查看'];
  53. }
  54. return ['error' => 0, 'msg' => '领取成功', 'data' => $_res];
  55. }
  56. }
  57. }