BaseStore.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /*
  3. * 店铺的类
  4. */
  5. namespace app\home\controller;
  6. use think\facade\View;
  7. use think\facade\Lang;
  8. /**
  9. *
  10. *
  11. * ----------------------------------------------------------------------------
  12. *
  13. * 控制器
  14. */
  15. class BaseStore extends BaseHome
  16. {
  17. protected $store_info;
  18. public function initialize()
  19. {
  20. parent::initialize();
  21. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/baseseller.lang.php');
  22. //店铺模板路径
  23. $this->template_dir = 'default/store/default/' . strtolower(request()->controller()) . '/';
  24. View::assign('store_theme', 'default');
  25. //当方法为 store 进行执行
  26. if (in_array(request()->controller(), array('Store', 'StoreSpecial'))) {
  27. //输出会员信息
  28. $this->getMemberAndGradeInfo(false);
  29. $store_id = intval(input('param.store_id'));
  30. if ($store_id <= 0) {
  31. $this->error(lang('ds_store_close'));
  32. }
  33. $store_model = model('store');
  34. $store_info = $store_model->getStoreOnlineInfoByID($store_id);
  35. if (empty($store_info)) {
  36. $this->error(lang('ds_store_close'));
  37. } else {
  38. $this->store_info = $store_info;
  39. }
  40. $storejoinin_model = model('storejoinin');
  41. if (!$store_info['is_platform_store']) {
  42. $storejoinin_info = $storejoinin_model->getOneStorejoinin(array('member_id' => $store_info['member_id']));
  43. //营业执照
  44. if ($storejoinin_info) {
  45. $this->store_info['business_licence_number_electronic'] = ($storejoinin_info['business_licence_number_electronic'] && $storejoinin_info['store_type'] == 0) ? get_store_joinin_imageurl($storejoinin_info['business_licence_number_electronic']) : '';
  46. }
  47. }
  48. $this->outputStoreInfo($this->store_info);
  49. $this->getStorenavigation($store_id);
  50. $this->outputSeoInfo($this->store_info);
  51. }
  52. }
  53. /**
  54. * 检查店铺开启状态
  55. *
  56. * @param int $store_id 店铺编号
  57. * @param string $msg 警告信息
  58. */
  59. protected function outputStoreInfo($store_info)
  60. {
  61. $store_model = model('store');
  62. //店铺分类
  63. $goodsclass_model = model('storegoodsclass');
  64. $goods_class_list = $goodsclass_model->getShowTreeList($store_info['store_id']);
  65. View::assign('goods_class_list', $goods_class_list);
  66. //热销排行
  67. $hot_sales = $store_model->getHotSalesList($store_info['store_id'], 5);
  68. View::assign('hot_sales', $hot_sales);
  69. //收藏排行
  70. $hot_collect = $store_model->getHotCollectList($store_info['store_id'], 5);
  71. View::assign('hot_collect', $hot_collect);
  72. View::assign('store_info', $store_info);
  73. View::assign('page_title', $store_info['store_name']);
  74. }
  75. protected function getStorenavigation($store_id)
  76. {
  77. $storenavigation_model = model('storenavigation');
  78. $store_navigation_list = $storenavigation_model->getStorenavigationList(array('storenav_store_id' => $store_id));
  79. View::assign('store_navigation_list', $store_navigation_list);
  80. }
  81. protected function outputSeoInfo($store_info)
  82. {
  83. $seo_param = array();
  84. $seo_param['shopname'] = $store_info['store_name'];
  85. $seo_param['key'] = $store_info['store_keywords'];
  86. $seo_param['description'] = $store_info['store_description'];
  87. //SEO 设置
  88. $this->_assign_seo(model('seo')->type('shop')->param($seo_param)->show());
  89. }
  90. }