Member.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. * DSMall多用户商城
  8. * ============================================================================
  9. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  10. * 网站地址: http://www.csdeshang.com
  11. * ----------------------------------------------------------------------------
  12. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  13. * 不允许对程序代码以任何形式任何目的的再发布。
  14. * ============================================================================
  15. * 控制器
  16. */
  17. class Member extends BaseMember {
  18. public function initialize() {
  19. parent::initialize();
  20. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/member.lang.php');
  21. }
  22. public function index() {
  23. //获取用户账号信息
  24. $member_info = $this->member_info;
  25. $member_info['security_level'] = model('member')->getMemberSecurityLevel($member_info);
  26. //代金券数量
  27. $member_info['voucher_count'] = model('voucher')->getCurrentAvailableVoucherCount(session('member_id'));
  28. View::assign('home_member_info', $member_info);
  29. //获取订单信息
  30. $order_list=array();
  31. $order_model = model('order');
  32. $refundreturn_model = model('refundreturn');
  33. $order_list['order_nopay_count'] = $order_model->getOrderCountByID('buyer', session('member_id'), 'NewCount');
  34. $order_list['order_noreceipt_count'] = $order_model->getOrderCountByID('buyer', session('member_id'), 'SendCount');
  35. $order_list['order_noeval_count'] = $order_model->getOrderCountByID('buyer', session('member_id'), 'EvalCount');
  36. $order_list['order_noship_count'] = $order_model->getOrderCountByID('buyer', session('member_id'), 'PayCount');
  37. $order_list['order_refund_count'] = $refundreturn_model->getRefundreturnCount(array(array('buyer_id','=',session('member_id')),array('refund_state','in',[1,2])));
  38. View::assign('home_order_info', $order_list);
  39. /* 设置买家当前菜单 */
  40. $this->setMemberCurMenu('selleralbum');
  41. /* 设置买家当前栏目 */
  42. $this->setMemberCurItem('my_album');
  43. return View::fetch($this->template_dir . 'index');
  44. }
  45. public function ajax_load_order_info() {
  46. //取出购物车信息
  47. $cart_model = model('cart');
  48. $cart_list = $cart_model->getCartList('db', array('buyer_id' => session('member_id')), 12);
  49. View::assign('cart_list', $cart_list);
  50. return View::fetch($this->template_dir . 'order_info');
  51. }
  52. public function ajax_load_point_info(){
  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. $favorites_model = model('favorites');
  69. $favorites_list = $favorites_model->getGoodsFavoritesList(array(array('member_id' ,'=', session('member_id'))), '*', 7);
  70. if (!empty($favorites_list) && is_array($favorites_list)) {
  71. $favorites_id = array(); //收藏的商品编号
  72. foreach ($favorites_list as $key => $favorites) {
  73. $fav_id = $favorites['fav_id'];
  74. $favorites_id[] = $favorites['fav_id'];
  75. $favorites_key[$fav_id] = $key;
  76. }
  77. $goods_model = model('goods');
  78. $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';
  79. $goods_list = $goods_model->getGoodsStoreList(array(array('goods_id','in', $favorites_id)), $field);
  80. $store_array = array(); //店铺编号
  81. if (!empty($goods_list) && is_array($goods_list)) {
  82. $store_goods_list = array(); //店铺为分组的商品
  83. foreach ($goods_list as $key => $fav) {
  84. $fav_id = $fav['goods_id'];
  85. $fav['goods_member_id'] = $fav['member_id'];
  86. $key = $favorites_key[$fav_id];
  87. $favorites_list[$key]['goods'] = $fav;
  88. }
  89. }
  90. }
  91. View::assign('favorites_list', $favorites_list);
  92. //店铺收藏
  93. $favorites_list = $favorites_model->getStoreFavoritesList(array(array('member_id' ,'=', session('member_id'))), '*', 6);
  94. if (!empty($favorites_list) && is_array($favorites_list)) {
  95. $favorites_id = array(); //收藏的店铺编号
  96. foreach ($favorites_list as $key => $favorites) {
  97. $fav_id = $favorites['fav_id'];
  98. $favorites_id[] = $favorites['fav_id'];
  99. $favorites_key[$fav_id] = $key;
  100. }
  101. $store_model = model('store');
  102. $store_list = $store_model->getStoreList(array(array('store_id','in', $favorites_id)));
  103. if (!empty($store_list) && is_array($store_list)) {
  104. foreach ($store_list as $key => $fav) {
  105. $fav_id = $fav['store_id'];
  106. $key = $favorites_key[$fav_id];
  107. $favorites_list[$key]['store'] = $fav;
  108. }
  109. }
  110. }
  111. View::assign('favorites_store_list', $favorites_list);
  112. $goods_count_new = array();
  113. if (!empty($favorites_id)) {
  114. foreach ($favorites_id as $v) {
  115. $count = model('goods')->getGoodsCommonOnlineCount(array(array('store_id' ,'=', $v)));
  116. $goods_count_new[$v] = $count;
  117. }
  118. }
  119. View::assign('goods_count', $goods_count_new);
  120. return View::fetch($this->template_dir . 'goods_info');
  121. }
  122. public function ajax_load_sns_info() {
  123. //我的足迹
  124. $goods_list = model('goodsbrowse')->getViewedGoodsList(session('member_id'), 20);
  125. $viewed_goods = array();
  126. if (is_array($goods_list) && !empty($goods_list)) {
  127. foreach ($goods_list as $key => $val) {
  128. $goods_id = $val['goods_id'];
  129. $val['url'] = (string)url('Goods/index',['goods_id'=>$goods_id]);
  130. $val['goods_image'] = goods_thumb($val, 240);
  131. $viewed_goods[$goods_id] = $val;
  132. }
  133. }
  134. View::assign('viewed_goods', $viewed_goods);
  135. return View::fetch($this->template_dir . 'sns_info');
  136. }
  137. }
  138. ?>