BasePointShop.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. /**
  5. * 积分中心control父类
  6. */
  7. /**
  8. * ============================================================================
  9. *
  10. * ============================================================================
  11. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  12. * 网站地址: https://www.valimart.net/
  13. * ----------------------------------------------------------------------------
  14. *
  15. * ============================================================================
  16. * 控制器
  17. */
  18. class BasePointShop extends BaseHome {
  19. protected $member_info;
  20. public function initialize() {
  21. parent::initialize();
  22. //输出会员信息
  23. $this->member_info = $this->getMemberAndGradeInfo(true);
  24. View::assign('member_info', $this->member_info);
  25. //判断系统是否开启积分和积分中心功能
  26. if (config('ds_config.points_isuse') != 1 || config('ds_config.pointshop_isuse') != 1) {
  27. $this->error(lang('pointshop_unavailable'), (string)url('Index/index'));
  28. }
  29. $this->template_dir = 'default/member/' . strtolower(request()->controller()) . '/';
  30. View::assign('index_sign', 'pointshop');
  31. }
  32. /**
  33. * 获得积分中心会员信息包括会员名、ID、会员头像、会员等级、经验值、等级进度、积分、已领代金券、已兑换礼品、礼品购物车
  34. */
  35. public function pointshopMInfo($is_return = false) {
  36. if (session('is_login') == '1') {
  37. $member_model = model('member');
  38. if (!$this->member_info) {
  39. //查询会员信息
  40. $member_infotmp = $member_model->getMemberInfoByID(session('member_id'));
  41. } else {
  42. $member_infotmp = $this->member_info;
  43. }
  44. $member_infotmp['member_exppoints'] = intval($member_infotmp['member_exppoints']);
  45. //当前登录会员等级信息
  46. $membergrade_info = $member_model->getOneMemberGrade($member_infotmp['member_exppoints'], true);
  47. $member_info = array_merge($member_infotmp, $membergrade_info);
  48. View::assign('member_info', $member_info);
  49. //查询已兑换并可以使用的代金券数量
  50. $voucher_model = model('voucher');
  51. $vouchercount = $voucher_model->getCurrentAvailableVoucherCount(session('member_id'));
  52. View::assign('vouchercount', $vouchercount);
  53. //购物车兑换商品数
  54. $pointcart_count = model('pointcart')->getPointcartCount(session('member_id'));
  55. View::assign('pointcart_count', $pointcart_count);
  56. //查询已兑换商品数(未取消订单)
  57. $pointordercount = model('pointorder')->getMemberPointsOrderGoodsCount(session('member_id'));
  58. View::assign('pointordercount', $pointordercount);
  59. if ($is_return) {
  60. return array('member_info' => $member_info, 'vouchercount' => $vouchercount, 'pointcart_count' => $pointcart_count, 'pointordercount' => $pointordercount);
  61. }
  62. }
  63. }
  64. }