Inviterpro.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. * ============================================================================
  13. * 控制器
  14. */
  15. class Inviterpro extends BaseMall {
  16. //每页显示商品数
  17. const PAGESIZE = 12;
  18. public function initialize() {
  19. parent::initialize();
  20. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/inviterpro.lang.php');
  21. }
  22. public function index() {
  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. }