Inviterpro.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 Inviterpro extends BaseMall
  13. {
  14. //每页显示商品数
  15. const PAGESIZE = 12;
  16. public function initialize()
  17. {
  18. parent::initialize();
  19. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/inviterpro.lang.php');
  20. }
  21. public function index()
  22. {
  23. $condition = array();
  24. $condition[] = array('gc_parent_id', '=', 0);
  25. $goods_class_array = model('goodsclass')->getGoodsclassList($condition);
  26. View::assign('goods_class_array', $goods_class_array);
  27. $goods_model = model('goods');
  28. if (!config('ds_config.inviter_open')) {
  29. $goods_list = array();
  30. } else {
  31. $condition = array();
  32. $condition[] = array('inviter_open', '=', 1);
  33. if (input('param.keyword')) {
  34. $condition[] = array('goods_name', 'like', '%' . input('param.keyword') . '%');
  35. }
  36. if (input('param.cate_id')) {
  37. $condition[] = array('gc_id_1|gc_id_2|gc_id_3', '=', intval(input('param.cate_id')));
  38. }
  39. $goods_list = $goods_model->getGoodsCommonList($condition, '*', self::PAGESIZE);
  40. foreach ($goods_list as $key => $goods) {
  41. $goods_info = $goods_model->getGoodsInfo(array('goods_commonid' => $goods['goods_commonid']), 'goods_id');
  42. $goods_list[$key]['goods_id'] = $goods_info['goods_id'];
  43. $goods_list[$key]['goods_image_url'] = goods_cthumb($goods['goods_image'], 240);
  44. $goods_list[$key]['inviter_amount'] = 0;
  45. if (config('ds_config.inviter_show')) {
  46. $inviter_amount = round($goods['inviter_ratio'] / 100 * $goods['goods_price'] * floatval(config('ds_config.inviter_ratio_1')) / 100, 2);
  47. if ($inviter_amount > 0) {
  48. $goods_list[$key]['inviter_amount'] = $inviter_amount;
  49. }
  50. }
  51. }
  52. }
  53. View::assign('goods_list', $goods_list);
  54. View::assign('show_page', is_object($goods_model->page_info) ? $goods_model->page_info->render() : "");
  55. // 当前位置导航
  56. View::assign('nav_link_list', array(array('title' => lang('homepage'), 'link' => (string)url('home/Index/index')), array('title' => lang('inviterpro_inviter_market'))));
  57. //SEO 设置
  58. $seo = array(
  59. 'html_title' => config('ds_config.site_name') . '-' . lang('inviterpro_inviter_market'),
  60. 'seo_keywords' => lang('inviterpro_inviter_market'),
  61. 'seo_description' => lang('inviterpro_inviter_market'),
  62. );
  63. $this->_assign_seo($seo);
  64. return View::fetch($this->template_dir . 'index');
  65. }
  66. }