Promotion.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  13. * 网站地址: https://www.valimart.net/
  14. * ----------------------------------------------------------------------------
  15. *
  16. * ============================================================================
  17. * 控制器
  18. */
  19. class Promotion extends BaseMall {
  20. const PAGESIZE = 16;
  21. public function initialize() {
  22. parent::initialize();
  23. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/promotion.lang.php');
  24. }
  25. public function index() {
  26. $xianshigoods_model = model('pxianshigoods');
  27. $goods_model = model('goods');
  28. $condition = array();
  29. $condition[]=array('xianshigoods_state','=',1);
  30. $condition[]=array('xianshigoods_starttime','<=', TIMESTAMP);
  31. $condition[]=array('xianshigoods_end_time','>', TIMESTAMP);
  32. $gc_id = intval(input('param.gc_id'));
  33. if ($gc_id) {
  34. $condition[]=array('gc_id_1','=',intval($gc_id));
  35. }
  36. $goods_list = $xianshigoods_model->getXianshigoodsExtendList($condition, self::PAGESIZE, 'xianshigoods_id desc');
  37. $xs_goods_list = array();
  38. foreach ($goods_list as $k => $goods_info) {
  39. $xs_goods_list[$goods_info['goods_id']] = $goods_info;
  40. $xs_goods_list[$goods_info['goods_id']]['image_url_240'] = goods_cthumb($goods_info['goods_image'], 240, $goods_info['store_id']);
  41. $xs_goods_list[$goods_info['goods_id']]['down_price'] = $goods_info['goods_price'] - $goods_info['xianshigoods_price'];
  42. }
  43. $condition = array(array('goods_id','in', array_keys($xs_goods_list)));
  44. $goods_list = $goods_model->getGoodsOnlineList($condition, 'goods_id,gc_id_1,evaluation_good_star,store_id,store_name', 0, '', self::PAGESIZE, null, false);
  45. $last_goods_list = array();
  46. foreach ($goods_list as $k => $goods_info) {
  47. $last_goods_list[$goods_info['goods_id']] = $xs_goods_list[$goods_info['goods_id']];
  48. $last_goods_list[$goods_info['goods_id']]['evaluation_good_star'] = $goods_info['evaluation_good_star'];
  49. $last_goods_list[$goods_info['goods_id']]['store_name'] = $goods_info['store_name'];
  50. if ($last_goods_list[$goods_info['goods_id']]['gc_id_1'] != $goods_info['gc_id_1']) {
  51. //兼容以前版本,如果秒杀商品表没有保存一级分类ID,则马上保存
  52. $xianshigoods_model->editXianshigoods(array('gc_id_1' => $goods_info['gc_id_1']), array('xianshigoods_id' => $last_goods_list[$goods_info['goods_id']]['xianshigoods_id']));
  53. }
  54. }
  55. //查询商品评分信息
  56. $goodsevallist = model('evaluategoods')->getEvaluategoodsList(array(array('geval_goodsid','in', array_keys($last_goods_list))));
  57. $eval_list = array();
  58. if (!empty($goodsevallist)) {
  59. foreach ($goodsevallist as $v) {
  60. if ($v['geval_content'] == '' || (isset($eval_list[$v['geval_goodsid']]) && count($eval_list[$v['geval_goodsid']]) >= 2))
  61. continue;
  62. $eval_list[$v['geval_goodsid']][] = $v;
  63. }
  64. }
  65. View::assign('goodsevallist', $eval_list);
  66. View::assign('goods_list', $last_goods_list);
  67. if (!empty(input('get.curpage'))) {
  68. return View::fetch($this->template_dir . 'item');
  69. } else {
  70. //导航
  71. $nav_link = array(
  72. 0 => array(
  73. 'title' => lang('homepage'),
  74. 'link' => HOME_SITE_URL,
  75. ),
  76. 1 => array(
  77. 'title' => lang('limited_time_discount')
  78. )
  79. );
  80. View::assign('nav_link_list', $nav_link);
  81. //查询商品分类
  82. $goods_class = model('goodsclass')->getGoodsclassListByParentId(0);
  83. View::assign('goods_class', $goods_class);
  84. View::assign('total_page', $xianshigoods_model->page_info->render());
  85. return View::fetch($this->template_dir . 'index');
  86. }
  87. }
  88. }
  89. ?>