BasePointShop.php 3.4 KB

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