Member.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. *
  7. *
  8. * ----------------------------------------------------------------------------
  9. *
  10. * 控制器
  11. */
  12. class Member extends BaseMember
  13. {
  14. public function initialize()
  15. {
  16. parent::initialize();
  17. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/member.lang.php');
  18. }
  19. public function index()
  20. {
  21. //获取用户账号信息
  22. $member_info = $this->member_info;
  23. $member_info['security_level'] = model('member')->getMemberSecurityLevel($member_info);
  24. //代金券数量
  25. $member_info['voucher_count'] = model('voucher')->getCurrentAvailableVoucherCount(session('member_id'));
  26. View::assign('home_member_info', $member_info);
  27. //获取订单信息
  28. $order_list = array();
  29. $order_model = model('order');
  30. $refundreturn_model = model('refundreturn');
  31. $order_list['order_nopay_count'] = $order_model->getOrderCountByID('buyer', session('member_id'), 'NewCount');
  32. $order_list['order_noreceipt_count'] = $order_model->getOrderCountByID('buyer', session('member_id'), 'SendCount');
  33. $order_list['order_noeval_count'] = $order_model->getOrderCountByID('buyer', session('member_id'), 'EvalCount');
  34. $order_list['order_noship_count'] = $order_model->getOrderCountByID('buyer', session('member_id'), 'PayCount');
  35. $order_list['order_refund_count'] = $refundreturn_model->getRefundreturnCount(array(array('buyer_id', '=', session('member_id')), array('refund_state', 'in', [1, 2])));
  36. View::assign('home_order_info', $order_list);
  37. /* 设置买家当前菜单 */
  38. $this->setMemberCurMenu('selleralbum');
  39. /* 设置买家当前栏目 */
  40. $this->setMemberCurItem('my_album');
  41. return View::fetch($this->template_dir . 'index');
  42. }
  43. public function ajax_load_order_info()
  44. {
  45. //取出购物车信息
  46. $cart_model = model('cart');
  47. $cart_list = $cart_model->getCartList('db', array('buyer_id' => session('member_id')), 12);
  48. View::assign('cart_list', $cart_list);
  49. return View::fetch($this->template_dir . 'order_info');
  50. }
  51. public function ajax_load_point_info()
  52. {
  53. //开启代金券功能后查询推荐的热门代金券列表
  54. if (config('ds_config.voucher_allow') == 1) {
  55. $recommend_voucher = model('voucher')->getRecommendTemplate(2);
  56. View::assign('recommend_voucher', $recommend_voucher);
  57. }
  58. //开启积分兑换功能后查询推荐的热门兑换商品列表
  59. if (config('ds_config.pointprod_isuse') == 1) {
  60. //热门积分兑换商品
  61. $recommend_pointsprod = model('pointprod')->getRecommendPointProd(2);
  62. View::assign('recommend_pointsprod', $recommend_pointsprod);
  63. }
  64. return View::fetch($this->template_dir . 'point_info');
  65. }
  66. public function ajax_load_goods_info()
  67. {
  68. //商品收藏
  69. $favorites_model = model('favorites');
  70. $favorites_list = $favorites_model->getGoodsFavoritesList(array(array('member_id', '=', session('member_id'))), '*', 7);
  71. if (!empty($favorites_list) && is_array($favorites_list)) {
  72. $favorites_id = array(); //收藏的商品编号
  73. foreach ($favorites_list as $key => $favorites) {
  74. $fav_id = $favorites['fav_id'];
  75. $favorites_id[] = $favorites['fav_id'];
  76. $favorites_key[$fav_id] = $key;
  77. }
  78. $goods_model = model('goods');
  79. $field = 'goods.goods_id,goods.goods_name,goods.store_id,goods.goods_image,goods.goods_price,goods.evaluation_count,goods.goods_salenum,goods.goods_collect,store.store_name,store.member_id,store.member_name,store.store_qq,store.store_ww';
  80. $goods_list = $goods_model->getGoodsStoreList(array(array('goods_id', 'in', $favorites_id)), $field);
  81. $store_array = array(); //店铺编号
  82. if (!empty($goods_list) && is_array($goods_list)) {
  83. $store_goods_list = array(); //店铺为分组的商品
  84. foreach ($goods_list as $key => $fav) {
  85. $fav_id = $fav['goods_id'];
  86. $fav['goods_member_id'] = $fav['member_id'];
  87. $key = $favorites_key[$fav_id];
  88. $favorites_list[$key]['goods'] = $fav;
  89. }
  90. }
  91. }
  92. View::assign('favorites_list', $favorites_list);
  93. //店铺收藏
  94. $favorites_list = $favorites_model->getStoreFavoritesList(array(array('member_id', '=', session('member_id'))), '*', 6);
  95. if (!empty($favorites_list) && is_array($favorites_list)) {
  96. $favorites_id = array(); //收藏的店铺编号
  97. foreach ($favorites_list as $key => $favorites) {
  98. $fav_id = $favorites['fav_id'];
  99. $favorites_id[] = $favorites['fav_id'];
  100. $favorites_key[$fav_id] = $key;
  101. }
  102. $store_model = model('store');
  103. $store_list = $store_model->getStoreList(array(array('store_id', 'in', $favorites_id)));
  104. if (!empty($store_list) && is_array($store_list)) {
  105. foreach ($store_list as $key => $fav) {
  106. $fav_id = $fav['store_id'];
  107. $key = $favorites_key[$fav_id];
  108. $favorites_list[$key]['store'] = $fav;
  109. }
  110. }
  111. }
  112. View::assign('favorites_store_list', $favorites_list);
  113. $goods_count_new = array();
  114. if (!empty($favorites_id)) {
  115. foreach ($favorites_id as $v) {
  116. $count = model('goods')->getGoodsCommonOnlineCount(array(array('store_id', '=', $v)));
  117. $goods_count_new[$v] = $count;
  118. }
  119. }
  120. View::assign('goods_count', $goods_count_new);
  121. return View::fetch($this->template_dir . 'goods_info');
  122. }
  123. public function ajax_load_sns_info()
  124. {
  125. //我的足迹
  126. $goods_list = model('goodsbrowse')->getViewedGoodsList(session('member_id'), 20);
  127. $viewed_goods = array();
  128. if (is_array($goods_list) && !empty($goods_list)) {
  129. foreach ($goods_list as $key => $val) {
  130. $goods_id = $val['goods_id'];
  131. $val['url'] = (string)url('Goods/index', ['goods_id' => $goods_id]);
  132. $val['goods_image'] = goods_thumb($val, 240);
  133. $viewed_goods[$goods_id] = $val;
  134. }
  135. }
  136. View::assign('viewed_goods', $viewed_goods);
  137. return View::fetch($this->template_dir . 'sns_info');
  138. }
  139. }