Member.php 7.1 KB

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